Statically initialising pthread attributes in dynamic dlls.

Corinna Vinschen
Mon Feb 22 11:34:00 GMT 2010

On Feb 22 10:33, Andrew West wrote:
> Trying to initialise a pthread attribute in a static variable seems
> to cause a segfault. I've attach a simple test case compiled using;
> g++ -g mutex.cpp -o mutex.dll -lpthread
> g++ -g test.cpp -o test.exe -ldl
> I've cropped the code down to the essential bits, so no error
> reporting if it can't find the dll, etc.
> The only other bits of information I can give which might or might
> not be helpful are;
> 1) Calling pthread_mutexattr_init in a static variable in the
> executable works.
> 2) If I remove the pthread_mutexattr_init/pthread_mutexattr_destroy
> calls it works.
> 3) Delaying the pthread_mutexattr_init call until the first time the
> Mutex class is used works BUT then the
> segfault happens when dlclose is called.
> I haven't managed to track down the cause of the segfault yet, I'm
> getting a bit lost in the debugger :/

I did.

It's the verifyable_object_isvalid() function in  The

  if ((*object)->magic != magic)

results in a SEGV since *object is NULL.  That should not be a problem,
in theory, since that's what the efault handler should be good for.
But for some reason, after this SEGV occured, nothing happens, it just

Are the constructors called before the exception handling has been
set up?  The _cytgtls::handle_exception methid is never called.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-developers mailing list