std::shared_mutex deadlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I observe a deadlock from time to time using the msvc + microsoft std
library and recently asked a question about std::shared_mutex in their dev
forum:
https://developercommunity.visualstudio.com/t/std::shared_mutex-deadlock/10299619#T-ND10299805

Now I would like to know if the gnu std library exhibits the same
behaviour.
(I just could not test the code on Linux yet.)

In short:
Thread C tries(!) to write access (lock via scoped_lock or unique_lock)
while Thread B already has(!) it shared locked - read access (via
std::shared_lock).
Meanwhile Thread A is also trying(!) to read access (via std::shared_lock)
the shared_mutex.

In order:
Thread B: std::shared_lock _(mutex); // ok - acquired and now waiting for
Thread A to finish
Thread C: std::scoped_lock _(mutex); // ok - stuck for now
Thread A: std::shared_lock _(mutex); // failure - stuck as well

-> Thread C should be stuck but Thread A should be able to acquire the
shared lock and continue but it is stuck as well.

Thank you.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux