[Gambas-devel] Undead enumerators?

Tobias Boege tobias at ...692...
Sat Jul 27 15:29:11 CEST 2013


On Sun, 21 Jul 2013, Beno?t Minisini wrote:
> Le 13/07/2013 10:56, Tobias Boege a ?crit :
> > Hi Benoit,
> >
> > I may have reported this earlier but now you can see it yourself and with a
> > bit more output.
> >
> > In gb.data I have to iterate over List.Current and all active enumerators
> > when the list structure changes, i.e. elements are added or removed, in
> > order to update their information.
> >
> > I use GB.BeginEnum(), .NextEnum(), .GetEnum() and .EndEnum() to do this
> > (it's the macros begin_all_references and end_all_references in c_list.c). I
> > have looked up the semantics in the code of the Collection class.
> >
> > However, the API doesn't give only active enumerators but seemingly all that
> > have existed up to this point.
> >
> > Compile gb.data (latest revision) like
> >
> > $ make clean; make "CPPFLAGS+=-DDEBUG_ENUMERATOR"
> >
> > and run the attached project. You'll notice the debugging output from the
> > List class and one undead enumerator appearing.
> >
> > Is this intended behaviour (because this API is not documented, I don't know
> > if it should only report active enumerators or dead ones, too, but it
> > doesn't make much sense to me)? It took me some time to realise that this
> > was the cause of some nasty double-frees in gb.data... I worked around this
> > by explicitly marking dead enumerators as invalid and skipping them later,
> > though, but maybe we could clear the situation up.
> >
> > Regards,
> > Tobi
> >
> 
> The API has been fixed in revision #5749. Stopped enumerators are not 
> returned anymore.
> 
> Moreover, in revision #5750, stopped enumerators are immediately freed 
> (before they were freed when the function returns or if the enumeration 
> is started again).
> 

I now finally tested and it's working now. Thanks. In a subsequent commit,
I will eventually kick the workaround stuff out.

Regards,
Tobi





More information about the Devel mailing list