On 7 November 2013 18:21, Saurabh T <saur...@hotmail.com> wrote:
> ----------------------------------------
>> From: fa...@kde.org
>> To: valgrind-users@lists.sourceforge.net
>> CC: saur...@hotmail.com
>> Subject: Re: [Valgrind-users] Helgrind 3.9.0: false positive with 
>> pthread_mutex_destroy
>> Date: Thu, 7 Nov 2013 17:25:57 +0100
>>
>> On Thursday 07 November 2013 16:22:56 Saurabh T wrote:
>>> Helgrind seems to be reporting false positive data race when
>>> pthread_mutex_destroy is called in a different thread from
>>> pthread_mutex_unlock. Unfortunately I cannot make a test case, sorry. But
>>> here's the relevant output:
>>> <snip>
>>
>> Can you prove that the destroy cannot happen during the unlock?
>
> Not without code of course, but I dont believe it can. It can however happen 
> *before* the unlock. I believe this is allowed by the standard? The code is 
> something like this:
> Thread 1:
>   locks
>   deletes
>   unlocks
> Thread 2:
>   locks
>   does_stuff
>   unlocks
>
> saurabh
>

That is most definitely wrong. Thread 1 destroys a locked mutex, and
according to 
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutex_init.html
:
> Attempting to destroy a locked mutex results in undefined behavior.

BR
Magnus Reftel

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to