[PATCH] Teach pthread checker about double unlocks
Dmitri Gribenko
gribozavr at gmail.com
Thu Mar 20 05:26:45 PDT 2014
On Thu, Mar 20, 2014 at 11:28 AM, Daniel Fahlgren <daniel at fahlgren.se> wrote:
> void foo() {
> pthread_mutex_init(&mtx, NULL);
> pthread_mutex_lock(&mtx);
> pthread_mutex_unlock(&mtx);
> pthread_mutex_unlock(&mtx);
> }
>
> should still yield a warning. However, if the call to pthread_mutex_init
> isn't present the checker shouldn't warn about the double unlock. I'll
> need to think more about this.
Note that due to the nature of the multithreaded code the call to
pthread_mutex_init() will be rarely visible to the analyzer through
inlining, I think.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the cfe-commits
mailing list