CYGWIN - GCC - C++ - multi-threaded apps - ACCESS VIOLATION

René Møller Fonseca fonseca@mip.sdu.dk
Wed Mar 7 13:22:00 GMT 2001


Hi,

I'm currently trying to make working multi threaded C++ applications
that utilize the win32 api directly (I do not use the POSIX threads
implementation). I'm getting ACCESS VIOLATIONs (win32 exception
0xc0000005) nearly on every run of my applications.

Looking at the assembler code generated from the C++ code it seems to me
that the threads use a shared table for exception handling. At some
point an entry of the table is read and dereferenced a number of times
and finally . Its the dereference that allways results in the ACCESSS
VIOLATION (mostly a dereference of a zero pointer but not allways). Can
anyone confirm or deny this?

Additional notes:
  1. The problem seems to occur only at the end of a scope.
  2. The problem gets worse if I instantiate temporary objects on the
stack.
  3. The problem seems to disappear when the threads do not call the
win32 api (calling Sleep(0) will most likely result in an access
violation).

Can I do something to make the C++ code multi thread safe by providing
each thread context its own table for exception handling (if thats the
problem) by calling some functions in libgcc.a at the entry point of the
threads.

Are there anyone out there who have built working multi threaded C++
apps in the cygwin environment?

I have tried different versions of GCC 2.95... (all based on 19991024)
including prebuilt MINGW distributions and have found no differences in
the behaviour.

I'm running similar apps under Linux (using "gcc version 2.96 20000731
(Red Hat Linux 7.0)") without experiencing any segmentation faults.

Hope, somebody can help me out.

Thanks,
René

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list