https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122401

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <[email protected]>:

https://gcc.gnu.org/g:14f7cfd292f18d9f83a9d4f36338b2399ad79a59

commit r16-4697-g14f7cfd292f18d9f83a9d4f36338b2399ad79a59
Author: Jonathan Wakely <[email protected]>
Date:   Fri Oct 24 11:38:22 2025 +0100

    libstdc++: Fix deadlock in shared_timed_mutex test [PR122401]

    The test_shared_relative function deadlocks on older Glibc versions that
    don't have pthread_rwlock_clockrdlock, because (as already mentioned
    earlier in the test file) pthread_rwlock_timedrdlock returns EDEADLK if
    the thread that already holds a write lock attempts to acquire read
    lock, causing std::shared_timed_mutex to loop forever.

    The fix is to do the invalid try_lock_shared_for call on a different
    thread. To avoid undefined behaviour, we need to make the same changes
    to all calls that try to acquire a lock that is already held.

    Also add missing -pthread for PR122401.

    libstdc++-v3/ChangeLog:

            PR libstdc++/122401
            * testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc:
            Do not try to acquire locks on the thread that already holds a
            lock. Add -pthread for et pthread.

    Reviewed-by: Mike Crowe <[email protected]>
    Reviewed-by: Tomasz KamiÅski <[email protected]>

Reply via email to