libgc bug when using Gnu C nested functions

Wed Aug 1 06:47:00 GMT 2012

This small program causes a libgc error when compiled and run in Cygwin:

     $ gcc gcerror.c -lgc -o x.exe
     $ ./x.exe
     GC Warning: Thread stack pointer 0x22aa98 out of range, pushing 

#include <gc/gc.h>
#include <stdio.h>

void *dummy;

void f (void (*x)())

int main ()
     int i;

     void g ()
         printf("%i\n", i);

     i = 42;
     dummy = GC_MALLOC(10);

     return 0;

The presence of a function call that is passed a pointer to
a Gnu C nested function with a closure seems to cause the problem:

     * There is no error if:

         - i is global;
         - i is not used in g;
         - g is called normally (not passed to f);
         - f is not called;
         - GC_MALLOC is not called;
         - GC_MALLOC is replaced with malloc.

     * There is still an error if:

         - f does not call g;
         - GC_MALLOC is called before f.

The bug also causes memory corruption when it occurs larger programs.

Programs with libgc and this construct always work correctly in Debian 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <>
-------------- next part --------------
Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list