This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] proposed fix for libstdc++/54352


In order to conform to  [thread.condition.condvarany]/5 and fix this
PR we need an ABI change to std::condition_variable_any, so that its
internal mutex can outlive the condition_variable_any while there are
threads blocked on the mutex, which this patch does by using a
shared_ptr to hold the mutex and making waiting threads share
ownership of that mutex.

The ABI change is handled similarly to the recent chrono::steady_clock
changes, using an inline namespace for the new versions and continuing
to export the old version from the library for compatibility with old
code.

Any thoughts or suggestions on improving this before I commit it to trunk?

I can no longer reproduce the valgrind errors, except by hacking in
changes to std::mutex to cause races, so I haven't been able to write
a test case that fails without this change, but I believe it's still
necessary for correctness.

        PR libstdc++/54352
        * include/std/condition_variable (condition_variable_any): Move into
        inline namespace _V2 and replace mutex member with shared_ptr<mutex>.
        * src/c++11/condition_variable.cc (condition_variable_any): Move
        definitions to ...
        * src/c++11/compatibility-condvar.cc (condition_variable_any): Here.
        * src/Makefile.am: Add new source file.
        * src/Makefile.in: Regenerate.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]