On Sat, 17 Oct 1998, Geoff Hutchison wrote:

> 
> >That error message seems to come from the DB routine __db_keyempty()
> >(the last function in db-2.4.14/common/db_err.c), although I can't
> >tell right off where it is being called from.
> 
> It's called in many places. The direct calling code is actually from
> htlib/DB2_db.cc.
> 
> >Has anyone seen this before or have any suggestions as to a good place
> >for me to start looking?
> 
> I'd start with the htsearch.cc code. Can you kill htsearch when run from
> the command line and a search for "("?
> 

Thanks for the reply.

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:

$ gdb /usr/local/etc/httpd/cgi-bin/htsearch 
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for
details.
GDB 4.16 (i386-unknown-freebsd), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) set environment REQUEST_METHOD=GET
(gdb) set environment QUERY_STRING=words=%28&method=boolean
(gdb) run
Starting program: /usr/local/etc/httpd/cgi-bin/htsearch 

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: 

--
   378  void
   379  Parser::parse(List *tokenList, ResultList &resultMatches)
   380  {
   381      tokens = tokenList;
   382      tokens->Start_Get();
   383      lookahead = lexan();
   384      expr(1);
   385
   386      ResultList  *result = (ResultList *) stack.pop();
   387      List                *elements = result->elements();
   388      DocMatch    *dm;
   389
--

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? 

Thanks folks. Not subscribed, please cc.


Regards.

Chuck O'Donnell

----------------------------------------------------------------------
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