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

            Bug ID: 463991
           Summary: Potential false positive (destruction of condition
                    variable being waited upon) with
                    std::condition_variable
    Classification: Developer tools
           Product: valgrind
           Version: 3.20 GIT
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: helgrind
          Assignee: jsew...@acm.org
          Reporter: pbs3...@googlemail.com
  Target Milestone: ---

Created attachment 155099
  --> https://bugs.kde.org/attachment.cgi?id=155099&action=edit
Code snippet copied from stackoverflow and fixed to compile

SUMMARY

Destroying a std::condition_variable after calling notify_all() results in a
helgrind warning "pthread_cond_destroy: destruction of condition variable being
waited upon", even though this behaviour is apparently allowed by the C++ spec
(http://en.cppreference.com/w/cpp/thread/condition_variable/~condition_variable).

See this stackoverflow question
(https://stackoverflow.com/questions/48093715/destruction-of-condition-variable-randomly-loses-notification)
for a full discussion, although only the posts by the OP and the user mevets
are worth reading. Ultimately it seems the program is correct, although the
discussion is contentious which is why I've included "potential" in the bug
report title.

STEPS TO REPRODUCE

Run the snippet in the stackoverflow question (also attached) under helgrind.

OBSERVED RESULT

The error message

==71731== Thread #1: pthread_cond_destroy: destruction of condition variable
being waited upon
==71731==    at 0x484AA83: ??? (in
/usr/libexec/valgrind/vgpreload_helgrind-amd64-linux.so)
==71731==    by 0x4959E3D: __gthread_cond_destroy (gthr-default.h:885)
==71731==    by 0x4959E3D: ~__condvar (std_mutex.h:141)
==71731==    by 0x4959E3D: std::condition_variable::~condition_variable()
(condition_variable.cc:36)
==71731==    by 0x1098DB: notify_on_delete::~notify_on_delete() (in a.out)
==71731==    by 0x109381: main (in a.out)

EXPECTED RESULT

No error messages.

SOFTWARE/OS VERSIONS

valgrind-3.20.0.GIT

Target: x86_64-pc-linux-gnu
gcc version 12.2.0 (GCC)

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

Reply via email to