Hello.
I've written a code from Anthony Williams's book - "Concurrency in action". It's a lookup table and sometimes there is a deadlock. If I replace shared_mutex into just mutex when there is no deadlock. I've tested it on gcc 7.2 and clang 5.0.
I have found the problem. It happens only in MSYS2/mingw. There are no any problems in linux, cygwin or boost. It happens only with c++17 shared_mutex on MSYS2/mingw.
You do not use the lock correctly. You need to apply the lock whenever the protected object (m_list) is accessed. This includes find_value(...).
The special thing about shared_mutex is that you can have read access from multiple thread but whenever the object is modified it is blocked. For an example see:
I'm sure I use lock correctly. I call "find_value" only when lock is held.
This code from the Anthony Williams's book - "Concurrency in action" with small and unimportant details. Do you have doubts about the code of former boost maintainer? :) And I can assure you I know what shared_mutex is about. Read this post carefully I have already found what causes the deadlock - it's a bug in MSYS2/mingw. I just don't know what to do with it.