[Gambas-devel] Undead enumerators?

Tobias Boege tobias at ...692...
Sat Jul 13 10:56:13 CEST 2013


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: undeadenum-0.0.1.tar.gz
Type: application/octet-stream
Size: 5046 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20130713/185d58ca/attachment.obj>


More information about the Devel mailing list