[Xapian-devel] xapian csharp bindings crash

Olly Betts olly at survex.com
Tue Jun 28 16:49:52 BST 2011


On Tue, Jun 28, 2011 at 02:48:44PM +0200, Greg wrote:
> On Mon, Jun 27, 2011 at 7:33 AM, Olly Betts <olly at survex.com> wrote:
> > If this is a search, why is it calling TermGenerator.SetFlags()?  That's
> > an index-time thing.
`
> I've actually wondered about it myself but I thought that it was
> called internally for some reason.

No, nothing calls TermGenerator implicitly.

> one thing we encountered was that xdb.Close() was required since the
> garbage collector wasn't releasing the objects fast enough which
> caused Xapian to throw a windows 'too many file handles open' or
> something to that effect but that was added some time ago.

That's largely why we added the close() method.  In garbage collected
languages, it's often not predictable when objects actually get
destroyed, so there really needs to be a way to release resources
other than memory before that.

> using (var xdb = OpenQueryDatabase(DBtype.AutoCompleteThreads))

Nothing looks obviously wrong here, but the mention of threads makes
me wonder - are you perhaps sharing Xapian objects between threads?
If so, it's your responsibility to ensure they aren't used from two
different threads at once.  Either you need a mutex or similar, or
just to use a different object in each thread.  Failing to do this
can cause weird behaviour, which potentially fits with what you are
seeing.

> 	xquery = qp.ParseQuery(query, (uint)Xapian.QueryParser.feature_flag.FLAG_PARTIAL);

Hmm, it's a shame that (uint) cast is needed there.  We should try
to avoid requiring that.

Cheers,
    Olly



More information about the Xapian-devel mailing list