Use ERRORCHECK mutexs
Submitted by Kurt Miller
Link to original bug (#674822)
Description
Created attachment 212829 Use PTHREAD_MUTEX_ERRORCHECK type mutexes by default
glibc's implementation of PTHREAD_MUTEX_ADAPTIVE_NP and PTHREAD_MUTEX_DEFAULT allows many application bugs to go unchecked and hide them by not failing. For example, unlocking a mutex that is not owned by the current thread is allowed, unlocking a mutex that is unowned is allowed.
As a result of glibc's implementation, applications that use glib will not know when there are application bugs which can have unpredictable consequences such has one thread unlocking another threads lock. These type of bugs lead to crashes that are very difficult to find. In addition, both PTHREAD_MUTEX_ADAPTIVE_NP and PTHREAD_MUTEX_DEFAULT type mutexes can be implemented differently across platforms because PTHREAD_MUTEX_ADAPTIVE_NP is non-portable and because PTHREAD_MUTEX_DEFAULT is not strictly defined by Posix.
With the introduction of checking the return values of pthread_mutex_lock/unlock in version 2.31.0 of glib, applications now behave differently across platforms.
I am proposing that glib explicitly set the mutex type to PTHREAD_MUTEX_ERRORCHECK so that serious application bugs are caught and reported on Linux as well as for consistant behavior across all platforms.
The following applications have issues that are hidden by the use of non-error check type mutexes: sonata, subtitleeditor, gftp, gajim
Patch 212829, "Use PTHREAD_MUTEX_ERRORCHECK type mutexes by default":
patch-glib_gthread-posix_c
Version: 2.32.x