[llvm-bugs] [Bug 39234] New: Regression: Thread-safety annotation tests are failing

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 9 13:21:20 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39234

            Bug ID: 39234
           Summary: Regression: Thread-safety annotation tests are failing
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ldionne at apple.com
                CC: aaronpuchert at alice-dsl.net, llvm-bugs at lists.llvm.org,
                    mclow.lists at gmail.com

The following libc++ tests started failing with Clang's r342605 (aka
7d2cf6756ab9485584e7ade8675a44bc9edd2a54 in the monorepo):

    FAIL: libc++ ::
libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
    FAIL: libc++ ::
libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
    FAIL: libc++ ::
libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
    FAIL: libc++ ::
libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp

r342605 is:

    Author: Aaron Puchert <aaronpuchert at alice-dsl.net>
    Date:   Thu Sep 20 00:39:27 2018 +0000

        Thread Safety Analysis: warnings for attributes without arguments

        Summary:
        When thread safety annotations are used without capability arguments,
        they are assumed to apply to `this` instead. So we warn when either
        `this` doesn't exist, or the class is not a capability type.

        This is based on earlier work by Josh Gao that was committed in
r310403,
        but reverted in r310698 because it didn't properly work in template
        classes. See also D36237.

        The solution is not to go via the QualType of `this`, which is then a
        template type, hence the attributes are not known because it could be
        specialized. Instead we look directly at the class in which we are
        contained.

        Additionally I grouped two of the warnings together. There are two
        issues here: the existence of `this`, which requires us to be a
        non-static member function, and the appropriate annotation on the class
        we are contained in. So we don't distinguish between not being in a
        class and being static, because in both cases we don't have `this`.


The errors look like:

    In file included from
[...]/llvm/projects/libcxx/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp:22:
    [...]/llvm/projects/libcxx/include/mutex:501:53: error:
'release_capability' attribute without capability arguments refers to 'this',
but 'scoped_lock<_Mutex>' isn't annotated with 'capability' or
'scoped_lockable' attribute [-Werror,-Wthread-safety-attributes]
        ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability())
{__m_.unlock();}
                                                        ^
    1 error generated.

Can you please investigate and suggest a fix to libc++? This failure wasn't
caught by the build bots because we apparently don't test libc++ ToT against
Clang ToT on a regular basis.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181009/c2951549/attachment.html>


More information about the llvm-bugs mailing list