libgc bug when using Gnu C nested functions
Glyn
gnwinorcon@orcon.net.nz
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
42
GC Warning: Thread stack pointer 0x22aa98 out of range, pushing
everything
*/
#include <gc/gc.h>
#include <stdio.h>
void *dummy;
void f (void (*x)())
{
x();
}
int main ()
{
int i;
void g ()
{
printf("%i\n", i);
}
i = 42;
f(g);
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
Stable.
*/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120801/9b6fa79f/attachment.ksh>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list