This is the mail archive of the
mailing list for the Cygwin project.
Re: Statically initialising pthread attributes in dynamic dlls.
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin-developers at cygwin dot com
- Date: Mon, 22 Feb 2010 12:34:16 +0100
- Subject: Re: Statically initialising pthread attributes in dynamic dlls.
- References: <4B825D76.email@example.com>
- Reply-to: cygwin-developers at cygwin dot com
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 :/
It's the verifyable_object_isvalid() function in thread.cc. 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