[Xapian-devel] xapian csharp bindings crash
Greg
freediving at gmail.com
Tue Jun 28 13:48:44 BST 2011
On Mon, Jun 27, 2011 at 7:33 AM, Olly Betts <olly at survex.com> wrote:
> On Sun, Jun 26, 2011 at 10:07:54AM +0200, Greg wrote:
>> On Sun, Jun 26, 2011 at 8:28 AM, Olly Betts <olly at survex.com> wrote:
>> > What version of Xapian are you using here?
>>
>> The version is 1.2.6, but it was crashing with 1.2.5 as well I just
>> didn't capture the dumps then.
>
> Thanks.
>
>> > Do you know if that's a plausible pointer value to a C++ heap
>> > allocated object in your environment?
>>
>> I don't know what do you mean by that
>
> On most platforms, the heap usually starts at a particular address. I'm
> just wondering if that's a garbage value, or a stale pointer to an
> object which has already been deallocated, or similar.
>
>> how should I check if the pointer is valid?
>
> Sorry, I've no idea how to do that on your platform. Though if you're
> getting an exception trying to read from it, it's not looking valid at
> that moment at least.
>
>> I'm not certain as to what seems to be the problem, I've printed out
>> the stack and the search that's being done isn't a special case trying
>> to call it again doesn't reproduce the problem, is there anything else
>> I could do to find the problem?
>
> If this is a search, why is it calling TermGenerator.SetFlags()? That's
> an index-time thing.
On Mon, Jun 27, 2011 at 7:33 AM, Olly Betts <olly at survex.com> wrote:
> On Sun, Jun 26, 2011 at 10:07:54AM +0200, Greg wrote:
>> On Sun, Jun 26, 2011 at 8:28 AM, Olly Betts <olly at survex.com> wrote:
>> > What version of Xapian are you using here?
>>
>> The version is 1.2.6, but it was crashing with 1.2.5 as well I just
>> didn't capture the dumps then.
>
> Thanks.
>
>> > Do you know if that's a plausible pointer value to a C++ heap
>> > allocated object in your environment?
>>
>> I don't know what do you mean by that
>
> On most platforms, the heap usually starts at a particular address. I'm
> just wondering if that's a garbage value, or a stale pointer to an
> object which has already been deallocated, or similar.
>
>> how should I check if the pointer is valid?
>
> Sorry, I've no idea how to do that on your platform. Though if you're
> getting an exception trying to read from it, it's not looking valid at
> that moment at least.
>
>> I'm not certain as to what seems to be the problem, I've printed out
>> the stack and the search that's being done isn't a special case trying
>> to call it again doesn't reproduce the problem, is there anything else
>> I could do to find the problem?
>
> 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. The code we're using is extremely
simple, it's C# but should be readable, 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.
I'm not exactly sure if there is a better way to destroy/release
objects if in fact the problem is with a pointer being garbage i.e.
it's already released. I've also changed the dlls on our production so
that they are compatible with the pdb-s which should hopefully provide
more information next time it happens.
using (var xdb = OpenQueryDatabase(DBtype.AutoCompleteThreads))
using (var enquire = new Enquire(xdb))
using (var qp = new QueryParser())
using (var stemmer = new Stem("english"))
{
qp.SetStemmer(stemmer);
qp.SetDatabase(xdb);
qp.SetDefaultOp(Query.op.OP_AND);
qp.SetStemmingStrategy(Xapian.QueryParser.stem_strategy.STEM_SOME);
Xapian.Query xquery = new Query();
xquery = qp.ParseQuery(query,
(uint)Xapian.QueryParser.feature_flag.FLAG_PARTIAL);
enquire.SetSortByValue(1);
enquire.SetQuery(xquery);
uint lefttoget = 10;
Xapian.MSet matches = new MSet();
try
{
matches = enquire.GetMSet(0, lefttoget);
}
catch (Exception ex)
{
Log.Error("FindInSmallThreadsDB", ex);
}
Xapian.MSetIterator m = matches.Begin();
while (m != matches.End())
{
threadresults.Add(new SearchResult()
{
DocType = ResultType.Message,
DocId = m.GetDocId(),
Percent = m.GetPercent(),
Weight = m.GetWeight(),
Rank = m.GetRank()
});
++m;
}
xdb.Close();
}
More information about the Xapian-devel
mailing list