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

前端 未结 2 661
攒了一身酷
攒了一身酷 2020-12-01 20:04

I am seeing a deadlock with std::mutex when the mutex is locked from DllMain() Below is a minimal DLL test case that exhibits the problem for me. M

2条回答
  •  遥遥无期
    2020-12-01 20:48

    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.

提交回复
热议问题