gpt4 book ai didi

visual-c++ - Visual Studio 2013 std::mutex 和可怕的 Windows 加载器锁

转载 作者:行者123 更新时间:2023-12-02 04:34:03 39 4
gpt4 key购买 nike

不久前,我在应用程序启动过程中遇到了一个问题,无法从DllMain()下面锁定互斥体:C++11 std::mutex in Visual Studio 2012 deadlock when locked from DllMain() 。我已经按照接受的答案中提到的方式进行了解决。

现在我遇到了类似的问题,但这次是由进程关闭引起的:

KernelBase.dll!RaiseException() Unknown
msvcr120d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 154 C++
msvcr120d.dll!Concurrency::details::SchedulerBase::SchedulerBase(const Concurrency::SchedulerPolicy & policy) Line 155 C++
msvcr120d.dll!Concurrency::details::ThreadScheduler::ThreadScheduler(const Concurrency::SchedulerPolicy & policy) Line 26 C++
msvcr120d.dll!Concurrency::details::ThreadScheduler::Create(const Concurrency::SchedulerPolicy & policy) Line 34 C++
msvcr120d.dll!Concurrency::details::SchedulerBase::CreateWithoutInitializing(const Concurrency::SchedulerPolicy & policy) Line 285 C++
msvcr120d.dll!Concurrency::details::SchedulerBase::GetDefaultScheduler() Line 654 C++
msvcr120d.dll!Concurrency::details::SchedulerBase::CreateContextFromDefaultScheduler() Line 571 C++
msvcr120d.dll!Concurrency::details::SchedulerBase::CurrentContext() Line 399 C++
msvcr120d.dll!Concurrency::details::LockQueueNode::LockQueueNode(unsigned int timeout) Line 619 C++
msvcr120d.dll!Concurrency::critical_section::lock() Line 1026 C++
msvcp120d.dll!mtx_do_lock(_Mtx_internal_imp_t * * mtx, const xtime * target) Line 67 C++
msvcp120d.dll!_Mtx_lock(_Mtx_internal_imp_t * * mtx) Line 154 C++
log4cplusUD.dll!std::_Mtx_lockX(_Mtx_internal_imp_t * * _Mtx) Line 68 C++
log4cplusUD.dll!std::_Mutex_base::lock() Line 42 C++
log4cplusUD.dll!log4cplus::thread::Mutex::lock() Line 80 C++
log4cplusUD.dll!log4cplus::thread::SyncGuard<log4cplus::thread::Mutex>::SyncGuard<log4cplus::thread::Mutex>(const log4cplus::thread::Mutex & m) Line 208 C++
log4cplusUD.dll!log4cplus::spi::ObjectRegistryBase::clear() Line 113 C++
log4cplusUD.dll!log4cplus::spi::FactoryRegistry<log4cplus::spi::LocaleFactory>::~FactoryRegistry<log4cplus::spi::LocaleFactory>() Line 156 C++
log4cplusUD.dll!log4cplus::`anonymous namespace'::DefaultContext::~DefaultContext() C++
log4cplusUD.dll!log4cplus::`anonymous namespace'::DefaultContext::`scalar deleting destructor'(unsigned int) C++
log4cplusUD.dll!log4cplus::`anonymous namespace'::destroy_default_context() Line 90 C++
log4cplusUD.dll!log4cplus::thread_callback(void * __formal, unsigned long fdwReason, void * __formal) Line 457 C++
log4cplusUD.dll!DllMain(HINSTANCE__ * hinstDLL, unsigned long fdwReason, void * lpReserved) Line 480 C++
log4cplusUD.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 508 C
log4cplusUD.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 473 C
ntdll.dll!LdrShutdownProcess() Unknown
ntdll.dll!RtlExitUserProcess() Unknown
msvcr120d.dll!__crtExitProcess(int status) Line 776 C
msvcr120d.dll!doexit(int code, int quick, int retcaller) Line 679 C
msvcr120d.dll!exit(int code) Line 426 C
timeformat_test.exe!__tmainCRTStartup() Line 662 C
timeformat_test.exe!mainCRTStartup() Line 466 C
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown

它引发的异常是 scheduler_resource_allocation_error 。这是由于 RegisterWaitForSingleObject() 调用失败引起的。

之前的解决方法没有帮助。我必须能够全局禁用各个类中所有互斥锁的锁定。

如果 Visual Studio 2013 不允许我在进程退出时进行清理,我到底该如何使用 C++11 线程和同步设施?

最佳答案

看来是VC2013的一个bug。我的应用程序中也发生了。我在这里创建了一份报告: https://connect.microsoft.com/VisualStudio/feedback/details/1282596

关于visual-c++ - Visual Studio 2013 std::mutex 和可怕的 Windows 加载器锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22402791/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com