https://bugs.kde.org/show_bug.cgi?id=453055

            Bug ID: 453055
           Summary: shared_timed_mutex drd test fails with "Lock shared
                    failed" message
           Product: valgrind
           Version: 3.19.0
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: drd
          Assignee: bart.vanassche+...@gmail.com
          Reporter: jch...@redhat.com
  Target Milestone: ---

Created attachment 148388
  --> https://bugs.kde.org/attachment.cgi?id=148388&action=edit
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

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to