[sword-devel] BUG in general book support

Troy A. Griffitts sword-devel@crosswire.org
Tue, 26 Feb 2002 20:25:59 -0700


Joachim,
	Did some hunting around and found a problem with your test program. 
Not sure if it might be the same in Bibletime.  Here's the scoop:

The offending line in your test program, below, is:

target->SetKey((SWKey*)*target);

The problem is that you are extracting a pointer to the SWKey of the
current module (this is ok), then expecting it to remain valid long
enough for a call to SetKey to complete, on the same module.

Here's the problem:  The process of setting a new key to a module
involves deleting the current key.  At this point your new key is
invalid, cuz it just got deleted.

Does that make sense?

I'll explain better if need be.  Changing the line to:

target->SetKey(listkey);

then adding:

cout << "First Entry Matching Search(" << target->KeyText() << "): " <<
*target << endl;

works just fine.

	Let me know,
		-Troy.




Joachim Ansorg wrote:
> 
> Troy,
>         Thank you for clearing this. I thought my mails are not read because nobody
> understands my english or because I'm nerving people with the bugs I found.
> 
> Joachim
> 
> > Joachim,
> >       Don't feel like we don't write you back!  Your posts usually require me
> > to do some investigation and debugging.  Know that I'm working on this
> > problem today.
> >
> >       -Troy.
> >
> > Joachim Ansorg wrote:
> > > Yesterday I debugged strange crashes in BibleTime which were related to
> > > GBS. But I had no success.
> > >
> > > Today I wote the following small testprogram:
> > >
> > > #include <stdio.h>
> > > #include <swmgr.h>
> > >
> > > int main(int argc, char **argv) {
> > >         SWMgr manager;
> > >         SWModule* target = manager.Modules["EnumaElish"];
> > >         ListKey listkey = target->Search("j", -2, 0, 0, 0);
> > >
> > >         cout << "Found: " << listkey.Count() << " keys"<< endl;
> > >
> > >         target->SetKey((SWKey*)*target);
> > > }
> > >
> > > The program terminates with "Found 22 keys.\n Segmentation fault". If I
> > > use BBE the program works without problems. I really have no idea what's
> > > causing this, since the problem occurs only with book modules and not
> > > with all search strings.
> > > I'm almost sure this bug causes some of BibleTime's crashes.
> > >
> > > I'd be glad for some help and an answer to this eMail!
> > > Joachim