-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper support for mutex type PTHREAD_MUTEX_ERRORCHECK
checking return types
#658
Comments
Are you sure? I think we have support for those. |
That support is questionable at best: analyzer/src/analyses/mutexAnalysis.ml Lines 165 to 171 in 179c8b9
Whether a memory access is a read or write (argument w ) has nothing to do with whether we're holding a read or write lock!Instead they relax one form of pairwise exclusion: reader-reader pairs do not mutually exclude each other. That's in no way reflected in the may_race check there.
This currently assumes the two notions are linked, i.e. read-write locks are correctly used that all writes use the write lock and not the read lock. |
That is also reflected by this existing regression test: analyzer/tests/regression/04-mutex/41-pt_rwlock.c Lines 9 to 24 in 179c8b9
Writer-reader pairs do mutually exclude each other, so there should be no race, but we report one because our assumption is violated since data2 is written under a read lock.
I suppose we might still be at least sound here, although we could also be more precise and prove both globals race-free by dropping our silly assumption. |
PTHREAD_MUTEX_ERRORCHECK
checking return types
With the revival of deadlock analysis (#655), it becomes more and more important that we handle behavior specific to mutex types.
Via
pthread_mutexattr_settype
there are the following possibilities:PTHREAD_MUTEX_DEFAULT
– misuse is undefined behaviorPTHREAD_MUTEX_NORMAL
– relocking deadlocks, other misuse is undefined behaviorPTHREAD_MUTEX_ERRORCHECK
– misuse returns errorsPTHREAD_MUTEX_RECURSIVE
– relocking allowed, other misuse returns errorsAdditionally:
pthread_rwlock_rdlock
,pthread_rwlock_wrlock
). (Fix read-write lock access handling #661)The different mutex types affect multiple features:
The text was updated successfully, but these errors were encountered: