这并不是什么时候可以安全地调用 std::stacktrace::current 的问题。 大多数事情在 DllMain 期间都是不允许的,DllMain 是运行 DLL 的全局构造函数的地方。 Microsoft 概述了最佳实践,但简而言之,您在全局构造函数中几乎不应该执行任何操作。 在这种情况下,获取堆栈跟踪看起来涉及间接调用 WinVerifyTrust,这可能会调用...
std::basic_stacktrace<Allocator>::current C++ Diagnostics library std::basic_stacktrace staticbasic_stacktrace current(constallocator_type&alloc= allocator_type())noexcept; (1)(since C++23) staticbasic_stacktrace current(size_type skip,constallocator_type&alloc= ...