| Summary: | shared_timed_mutex drd test fails with "Lock shared failed" message | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Jesus Checa <jcheca> |
| Component: | drd | Assignee: | Paul Floyd <pjfloyd> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | pjfloyd |
| Priority: | NOR | ||
| Version First Reported In: | 3.19.0 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Proposed fix for drd/tests/shared_timed_mutex | ||
LGTM This was my badly written testcase. To ssh://sourceware.org/git/valgrind.git 6af21da95..184e3ba05 master -> master |
Created attachment 148388 [details] Proposed fix for drd/tests/shared_timed_mutex SUMMARY drd/tests/shared_timed_mutex test fails in 3.19.0 during `make regtest`. This is also reproducible in 3.20.0.GIT: ================================================= drd/tests/shared_timed_mutex.stderr.diff ================================================= --- shared_timed_mutex.stderr.exp 2022-04-11 10:27:12.000000000 -0400 +++ shared_timed_mutex.stderr.out 2022-04-26 03:53:54.116981437 -0400 @@ -1,3 +1,4 @@ +Lock shared failed ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Running the test without valgrind seems to fail always as well. The problem seems to come from this code from the test itself: ``` for (i = 0; i < 3 && std::chrono::steady_clock::now() < then; ++i) { if (test_mutex.try_lock_shared_until(then)) { test_mutex.unlock_shared(); } } if (i == 3) { std::cerr << "Lock shared failed\n"; } ``` IIUIC, variable `i` will always be 3 in this code, hence the test will always print "Lock shared failed" and will mismatch the expected output. Adding a break as in the proposed patch fixes the issue. Tested in rhel-8 in x86_64, aarch64 and s390x. STEPS TO REPRODUCE 1. git clone git://sourceware.org/git/valgrind.git 2. cd valgrind && ./autogen.sh && ./configure 3. make -j$(nproc) regtest