[Xapian-discuss] seg fault on search

Olly Betts olly at survex.com
Tue Jan 21 19:28:43 GMT 2014


On Tue, Jan 21, 2014 at 04:53:41PM +0000, Michael Lewis wrote:
> I have written a very simple function to return the match count based
> on the simplesearch.cc code. It fails with a seg fault. The relevant
> code is:
> --------------------
> int ftQuery(char* qs, const char* dbname,char* results, int msize) {
>         long            docid;

It would be better to use the type Xapian::docid instead of long, though
that won't give you a segfault here.

> The query string is "austria" and it works with simplesearch.com. I
> have verified that the string is being passed to the function
> correctly as is the database name. I am out of ideas and wonder if
> anyone can point out anything that I am overlooking.

Code looks OK - I suspect the problem is elsewhere - e.g. maybe you've
corrupted the malloc heap or have a stray pointer write.

If you're on a supported platform, I'd run it under valgrind, which can
often spot such problems.

If you aren't, or that doesn't find anything, run it under gdb and get a
backtrace for exactly where the segfault happens - that will likely give
more of a clue.

Cheers,
    Olly



More information about the Xapian-discuss mailing list