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 :/
Andy
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
struct Mutex {
Mutex()
{
pthread_mutexattr_init( &_attr );
pthread_mutexattr_settype( &_attr, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( &_mutex, &_attr );
}
~Mutex()
{
pthread_mutex_destroy( &_mutex );
pthread_mutexattr_destroy( &_attr );
}
protected:
pthread_mutex_t _mutex;
pthread_mutexattr_t _attr;
};
static Mutex mymutex;
void __EntryPoint()
{
printf( "In mutex.dll\n" );
}
#include <dlfcn.h>
int main( int argc, char** argv )
{
void* dll = dlopen( "mutex.dll", RTLD_NOW );
dlclose( dll );
}
--
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