You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Jiri Daněk (Jira)" <ji...@apache.org> on 2020/11/10 09:20:00 UTC

[jira] [Created] (PROTON-2294) pthread_mutex_lock failing with EINVAL in proactor tests

Jiri Daněk created PROTON-2294:
----------------------------------

             Summary: pthread_mutex_lock failing with EINVAL in proactor tests
                 Key: PROTON-2294
                 URL: https://issues.apache.org/jira/browse/PROTON-2294
             Project: Qpid Proton
          Issue Type: Bug
          Components: proton-c
    Affects Versions: proton-c-0.33.0
            Reporter: Jiri Daněk


Functions {{pthread_mutex_lock}} and {{pthread_mutex_unlock}} return a status code. The status is not checked in Proton code, and any errors are therefore ignored.

According to notes on https://reviews.llvm.org/D18132?id=50550, which is the CL that implements the  {{ReportTypeMutexInvalidAccess}} TSan check, ignoring the status there is standard practice. Hence the need for the ASan check.

The TSan warnings that were suppressed in {{# PROTON-2292 & PROTON-1496: false suspected collision between set/free}} only highlight a nonzero return code from the aforementioned functions. This can be demonstrated if return code check is inserted. 

The TSan warnings are not concerned with potentialities (the way Coverity works), it reports the warnings as it sees the program to execute, and the undefined behavior is happening. There can be false positives, but this is probably not it.

In c-proactor-test/proactor_disconnect test, {{pthread_mutex_lock}} returns 22, which is EINVAL.

{code}
static inline void lock(pmutex *m) {
    int err = pthread_mutex_lock(m);
    if (err != 0) {
        fprintf(stderr, "Error locking mutex: %s\n", strerror(err));
        exit(1);
    }
}
static inline void unlock(pmutex *m) {
    int err = pthread_mutex_unlock(m);
    if (err != 0) {
        fprintf(stderr, "Error unlocking mutex: %s\n", strerror(err));
        exit(1);
    }
}
{code}

{noformat}
/home/jdanek/repos/qpid/qpid-proton/cmake-build-debugwithtsan/c/tests/c-proactor-test -r xml -d yes --order lex
Testing started at 9:53 AM ...
==================
WARNING: ThreadSanitizer: use of an invalid mutex (e.g. uninitialized or destroyed) (pid=27191)
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x4284b)
    #1 lock /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll-internal.h:329 (libqpid-proton-proactor.so.1+0xbb27)
    #2 pni_timer_set /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll_timer.c:248 (libqpid-proton-proactor.so.1+0xbb27)
    #3 pni_timer_free /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll_timer.c:144 (libqpid-proton-proactor.so.1+0xbe3a)
    #4 pconnection_final_free /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll.c:797 (libqpid-proton-proactor.so.1+0xc1a0)
    #5 pconnection_cleanup /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll.c:814 (libqpid-proton-proactor.so.1+0xc2f7)
    #6 pconnection_forced_shutdown /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll.c:855 (libqpid-proton-proactor.so.1+0x14c9d)
    #7 pn_proactor_free /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll.c:1994 (libqpid-proton-proactor.so.1+0x14c9d)
    #8 pn_test::auto_free<pn_proactor_t, &pn_proactor_free>::~auto_free() /home/jdanek/repos/qpid/qpid-proton/c/tests/././pn_test.hpp:53 (c-proactor-test+0x4355aa)
    #9 pn_test::proactor::~proactor() /home/jdanek/repos/qpid/qpid-proton/c/tests/./pn_test_proactor.hpp:38 (c-proactor-test+0x415149)
    #10 ____C_A_T_C_H____T_E_S_T____26 /home/jdanek/repos/qpid/qpid-proton/c/tests/proactor_test.cpp:677 (c-proactor-test+0x4329e1)
    #11 Catch::FreeFunctionTestCase::invoke() const /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7415 (c-proactor-test+0x454059)
    #12 Catch::TestCase::invoke() const /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:8413 (c-proactor-test+0x454059)
    #13 Catch::RunContext::invokeActiveTestCase() /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:6941 (c-proactor-test+0x454059)
    #14 Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:6911 (c-proactor-test+0x454059)
    #15 Catch::RunContext::runTest(Catch::TestCase const&) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:6706 (c-proactor-test+0x454059)
    #16 Catch::runTests(Catch::Ptr<Catch::Config> const&) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7086 (c-proactor-test+0x454059)
    #17 Catch::Session::runInternal() /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7258 (c-proactor-test+0x40d93c)
    #18 Catch::Session::run() /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7217 (c-proactor-test+0x40d93c)
    #19 Catch::Session::run(int, char const* const*) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7182 (c-proactor-test+0x40d93c)
    #20 main /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:11469 (c-proactor-test+0x40d93c)

  Location is heap block of size 1152 at 0x7b6400000500 allocated by main thread:
    #0 calloc <null> (libtsan.so.0+0x2f905)
    #1 pn_proactor /home/jdanek/repos/qpid/qpid-proton/c/src/proactor/epoll.c:1942 (libqpid-proton-proactor.so.1+0xca64)
    #2 pn_test::proactor::proactor(pn_test::handler*) /home/jdanek/repos/qpid/qpid-proton/c/tests/pn_test_proactor.cpp:45 (c-proactor-test+0x4139c9)
    #3 ____C_A_T_C_H____T_E_S_T____26 /home/jdanek/repos/qpid/qpid-proton/c/tests/proactor_test.cpp:677 (c-proactor-test+0x42fe5a)
    #4 Catch::FreeFunctionTestCase::invoke() const /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7415 (c-proactor-test+0x454059)
    #5 Catch::TestCase::invoke() const /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:8413 (c-proactor-test+0x454059)
    #6 Catch::RunContext::invokeActiveTestCase() /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:6941 (c-proactor-test+0x454059)
    #7 Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:6911 (c-proactor-test+0x454059)
    #8 Catch::RunContext::runTest(Catch::TestCase const&) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:6706 (c-proactor-test+0x454059)
    #9 Catch::runTests(Catch::Ptr<Catch::Config> const&) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7086 (c-proactor-test+0x454059)
    #10 Catch::Session::runInternal() /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7258 (c-proactor-test+0x40d93c)
    #11 Catch::Session::run() /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7217 (c-proactor-test+0x40d93c)
    #12 Catch::Session::run(int, char const* const*) /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:7182 (c-proactor-test+0x40d93c)
    #13 main /home/jdanek/repos/qpid/qpid-proton/tests/include/catch.hpp:11469 (c-proactor-test+0x40d93c)

  Mutex M0 (0x7b64000005c0) created at:
    [failed to restore the stack]

SUMMARY: ThreadSanitizer: use of an invalid mutex (e.g. uninitialized or destroyed) (/nix/store/zhbhxp4jgalycwffildy2bwcgmrsmayk-gcc-9.2.0-lib/lib/libtsan.so.0+0x4284b) in pthread_mutex_lock
==================
Error locking mutex: Invalid argument
ThreadSanitizer: reported 1 warnings
Process finished with exit code 66
{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org