thread-safety warnings, specifically try_acquire_capability

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

thread-safety warnings, specifically try_acquire_capability

Richard Smith via cfe-dev
I'm trying to use the annotations on some existing code, with (I
think) success, mostly. There's some code that conditionally locks
mutexes, and I note that's not supported so some code reorganisation
was needed.

What I can't seem to get to work is trylock(). I have some code which
does something like

    if (!mutex_.trylock()) {
       return;
    }
    ...
    mutex_.unlock();

and that doesn't work at all. I always seem to get complaints that
mutex_ might not be locked. Is this just an extension of the
unsupported nature of conditional locking? i.e., is there currently no
useful way to use the try_acquire_capability attribute (beyond
documentation)? (Not a horrible restriction for this code, but I'd
have thought it would be useful to mention it in the docs.)
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: thread-safety warnings, specifically try_acquire_capability

Richard Smith via cfe-dev
On Thu, Jan 18, 2018 at 12:36 PM, Bruce Stephens via cfe-dev
<[hidden email]> wrote:

> I'm trying to use the annotations on some existing code, with (I
> think) success, mostly. There's some code that conditionally locks
> mutexes, and I note that's not supported so some code reorganisation
> was needed.
>
> What I can't seem to get to work is trylock(). I have some code which
> does something like
>
>     if (!mutex_.trylock()) {
>        return;
>     }
>     ...
>     mutex_.unlock();
>
> and that doesn't work at all. I always seem to get complaints that
> mutex_ might not be locked. Is this just an extension of the
> unsupported nature of conditional locking? i.e., is there currently no
> useful way to use the try_acquire_capability attribute (beyond
> documentation)? (Not a horrible restriction for this code, but I'd
> have thought it would be useful to mention it in the docs.)
I believe i have reported the same bug already:
https://bugs.llvm.org/show_bug.cgi?id=32954

Roman.

> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: thread-safety warnings, specifically try_acquire_capability

Richard Smith via cfe-dev
Oh yes, that's the same. (I should have checked the bug database first.)

On 18 January 2018 at 09:45, Roman Lebedev <[hidden email]> wrote:

> On Thu, Jan 18, 2018 at 12:36 PM, Bruce Stephens via cfe-dev
> <[hidden email]> wrote:
>> I'm trying to use the annotations on some existing code, with (I
>> think) success, mostly. There's some code that conditionally locks
>> mutexes, and I note that's not supported so some code reorganisation
>> was needed.
>>
>> What I can't seem to get to work is trylock(). I have some code which
>> does something like
>>
>>     if (!mutex_.trylock()) {
>>        return;
>>     }
>>     ...
>>     mutex_.unlock();
>>
>> and that doesn't work at all. I always seem to get complaints that
>> mutex_ might not be locked. Is this just an extension of the
>> unsupported nature of conditional locking? i.e., is there currently no
>> useful way to use the try_acquire_capability attribute (beyond
>> documentation)? (Not a horrible restriction for this code, but I'd
>> have thought it would be useful to mention it in the docs.)
> I believe i have reported the same bug already:
> https://bugs.llvm.org/show_bug.cgi?id=32954
>
> Roman.
>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev