Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pthread mutex assertion error

I'm encountering the following error at unpredictable times in a linux-based (arm) communications application:

pthread_mutex_lock.c:82: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. 

Google turns up a lot of references to that error, but little information that seems relevant to my situation. I was wondering if anyone can give me some ideas about how to troubleshoot this error. Does anyone know of a common cause for this assertion?

Thanks in advance.

like image 317
Dave Causey Avatar asked Jul 09 '09 18:07

Dave Causey


People also ask

Can pthread_mutex_lock fail?

The pthread_mutex_lock() function may fail if: [EDEADLK] A deadlock condition was detected or the current thread already owns the mutex.

Is Pthread mutex lock blocking?

The pthread_mutex_lock() function locks mutex. If the mutex is already locked, the calling thread will block until the mutex becomes available. So yes - your thread is blocked until the lock is available and it can obtain it.

What is Pthread mutex?

int pthread_mutex_lock(pthread_mutex_t *mutex) : Locks a mutex object, which identifies a mutex. If the mutex is already locked by another thread, the thread waits for the mutex to become available. The thread that has locked a mutex becomes its current owner and remains the owner until the same thread has unlocked it.


1 Answers

Rock solid for 4 days straight. I'm declaring victory on this one. The answer is "stupid user error" (see comments above). A mutex should only be unlocked by the thread that locked it. Thanks for bearing with me.

like image 118
Dave Causey Avatar answered Oct 07 '22 08:10

Dave Causey