At 2:22 PM -0400 10/19/98, Chuck O'Donnell wrote:
>Looking for the reason that htsearch exits with SIGSEGV when searching
>for "(" on a boolean search instead of returning a "syntax error" or
>"no match":
>
>Here's what I found using gdb:
...
>Program received signal SIGSEGV, Segmentation fault.
>Dictionary::Start_Get (this=0x0) at Dictionary.cc:319
>319         currentTableIndex = -1;
>(gdb) bt
>#0  Dictionary::Start_Get (this=0x0) at Dictionary.cc:319
>#1  0x3db2 in ResultList::elements (this=0x0) at ResultList.cc:105
>#2  0x6c01 in Parser::parse (this=0x5b600, tokenList=0xefbfd85c,
>    resultMatches=@0x5f300) at parser.cc:387
>#3  0x60ce in htsearch (wordfile=0x5f180
>"/usr/local/htdig/db/db.words.db",
>    searchWords=@0xefbfd85c, parser=0x5b600) at htsearch.cc:606
>#4  0x4f64 in main (ac=1, av=0xefbfd89c) at htsearch.cc:190
>(gdb)
>--
>
>Then trying to find out why "ResultList::elements (this=0x0)" is NULL,
>we find in Parser::parse, line 387 of htsearch/parser.cc:
...
>At line 386 and 387, "result" is not checked for NULL.
>
>From here, it would be helpful if someone more familiar with the
>internals of htsearch could shed some light on a few things. I don't
>know if the pointer returned from stack.pop() is not checked because
>there should be pre-condition that the stack is never empty, or if
>it's just that the check for NULL on the return value was overlooked.
>And if the latter, what action is reasonable. Any thoughts?

>From htlib/Stack.cc
//***************************************************************************
// Object *Stack::pop()
// PURPOSE:
//    Return the object at the top of the stack and remove it from the stack.
//
Object *Stack::pop()
{
   if (size == 0)
      return 0;
...

So if the stack is empty, it returns NULL. So the check was overlooked. I'm
not sure what a good error condition would be. I don't know where it was
called in the first place.

One option is to just return and have the calling function find that it
didn't get any results. The other option is to return a value and have the
calling function find the error through the returned value.


-Geoff Hutchison
Williams Students Online
http://wso.williams.edu/


----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
[EMAIL PROTECTED] containing the single word "unsubscribe" in
the body of the message.

Reply via email to