[Gc] GC7.0 Release problem [HACKED]

Christophe Meessen meessen at cppm.in2p3.fr
Sat Jul 7 05:51:19 PDT 2007


The problem is not related to local stoage but to an initialization
problem.

GC_init_inner gets called instead of GC_init. This is because C++
allocate some blocks in its initialization phase before main is called.
In my case GC_malloc_uncollectable was called before GC was initialized.
This call checks if GC is initialized and if not it calls GC_init_inner.
GC_init_inner sets the flag that GC is initialized but it does not
initialize the critical section. This is done in GC_init that calls
GC_init_inner.

When GC_INIT is called in main, it then does nothing because the flag
tells it that it is already initialized. So the critical section is not
initialized.
The hack I did was to add the following instruction in front of
GC_malloc_uncollectable.

    if (!GC_is_initialized) GC_init();

There are a few other places where GC_init_inner is called instead of
GC_init. This problem shows up only with windows because of the window
specific code in GC_init. If the above instruction is added, the later
equivalent test and call to GC_init_inner should be removed.

It would be preferable to put this instruction in front of all gc calls
and then get rid of the GC_INIT call in the main routine.

With this hack my code now runs in release and debug mode.



More information about the Gc mailing list