[sword-devel] BUG in general book support

David White sword-devel@crosswire.org
27 Feb 2002 20:35:06 +1100


Why is it that containers have to "set" the key they are operating on?
This seems a little awkward to me.

I think it would be a good idea to move towards supporting full-strength
bidirectional or random-access iterators across modules, compliant with
the specifications of the C++ standard, so as to allow the maximum
interoperability with the C++ standard library, and other standard-style
libraries.

I'm thinking of something that would allow me to do things like this for
output:

copy(module.begin("John 3:1"), module.end("John 3:18"),
ostream_iterator(cout));

to output the passage John 3:1-John 3:18.

-David.

On Wed, 2002-02-27 at 14:25, Troy A. Griffitts wrote:
> 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