1

This says that we can debug std::mutex and indeed, it shows the 'thread' ID locked by the owning thread.

This unfortunately doesn't work with std::shared_mutex, I only see a 'myHandle' value. The natvis code doesn't work at all.

Any workaround with this? I 'm trying to debug a locking issue and I can't seem to find a way to know which thread locks (exclusively) the mutex.

Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78
  • A `std::shared_mutex` is not owned by a single thread right? Only one thread owns it in exclusive mode (write access). So I mean, it is not a blocking mutex for reading, just writing. – Xander Feb 04 '22 at 21:01
  • @Xander yes, obviously I'm concerned with exclusive access - edited. – Michael Chourdakis Feb 04 '22 at 21:03
  • I don't really see an easy alternative to achieve this `shared_lock`/`shared_mutex`. You could maybe try manually using the `std::mutex` to really understand what is going on. Other than that you can maybe share some code to explain your actual issue. – Xander Feb 04 '22 at 21:14
  • It's based on Slim Writer/Readed [locks](https://learn.microsoft.com/en-us/windows/win32/sync/slim-reader-writer--srw--locks) – Michael Chourdakis Feb 05 '22 at 07:06
  • 1
    Does this answer your question? [Find who holds a SRW Lock for a native process with WinDbg](https://stackoverflow.com/questions/60947806/find-who-holds-a-srw-lock-for-a-native-process-with-windbg) – Simon Mourier Feb 05 '22 at 07:16

0 Answers0