Manuel Teira wrote:
Hello.

It seems that the dreaded Mutex initialization assert is not completely gone. After compiling the unit_test executable, it asserts while trying to run it, in qpid::sys::Mutex::Mutex(), trying to use a non initialized recursiveMutexAttr.

The abort stack indicates that it is happening in the qpid::sys::DeletionManager::AllThreadStatuses int constructor, I suppose that while creating the static allThreadStatuses object.

Can you post a stack trace and the perror message that went with the failure?

I suspect that it has something to do with static initialization order. So, I replaced the QPID_POSIX_ASSERT_THROW_IF wrapping the pthread_mutex_init call in qpid::sys::Mutex::Mutex(), to allow the program to continue, with:

 if (pthread_mutex_init(&mutex, recursiveMutexattr) != 0) {
   std::cout << "Error initializing mutex: " << &mutex
             << ". " << std::strerror(errno) << std::endl;
 }

I also added some logs in the initMutexattr function:
std::cout << "initMutexattr[" << pthread_self() << "](once: " << &onceControl << ", mutexattr: " << &mutexattr
                   << ")" << std::endl;
in the Mutex constructor and in the AllThreadStatuses constructor to verify that the mutex is being used before the recursiveMutexAttr gets initialized:

initMutexattr[1](once: 0xffffffff7e14e300, mutexattr: 0xffffffff7e1535f8)
initMutexattr[1](once: 0xffffffff7e14e620, mutexattr: 0xffffffff7e1535d8)
Mutex::Mutex with mutex at 0xffffffff7e14e680 and pthread_mutex_attr_t at 0x0000000100400758
Error initializing mutex: 0xffffffff7e14e680. Error 0
AllThreadsStatuses ctor. Mutex: 0xffffffff7e14e680

[snip lots of other initMutexattr and Mutex::Mutex nonrelated calls]
initMutexattr[1](once: 0x00000001003f7730, mutexattr: 0x0000000100400758)


I suspect that the static nature of AllThreadStatuses could be involved. Any thought?


Order of static initializers would be my favourite suspect also. I'll take a look when I have a stack trace.

Reply via email to