C++11 std::mutex in Visual Studio 2012 deadlock when locked from DllMain()

Check the Best Practices for Creating DLLs document:

You should never perform the following tasks from within DllMain:

  • Call LoadLibrary or LoadLibraryEx (either directly or indirectly). This can cause a deadlock or a crash.
  • Synchronize with other threads. This can cause a deadlock.

Leave a Comment