This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc / atexit() threading problem


Back in July 2002 I reported a problem I was having with newlib in
Cygwin.  Christopher Faylor forwarded my message to this list:

http://sources.redhat.com/ml/newlib/2002/msg00368.html

I would like to eliminate the patch I am currently using to
work around the problem.  Here is some more information
for the newlib wizards -- perhaps there is an easy fix
for this that could be rolled into newlib.

The gcc compiler inserts calls to atexit() for static objects
declared inside functions, to schedule the destructor to be called
at program exit time.  E.g.:

f()
{
    // this results in a call to atexit() when the function enters
    static some_class o;
}

This can cause problems in Cygwin binaries because atexit()
is not thread-safe.  So what happens sometimes is that more than
one thread calls atexit() at the same time as part of a static
object constructor call, and the function pointer list used by
atexit() gets corrupted.

If there is a mechanism in newlib to lock the appropriate data
structure, I would appreciate it if this could be added.
--
Joe Buehler



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]