backward-cpp
backward-cpp copied to clipboard
Symbols only loaded after second attempt on windows
When I run this code on windows:
#include "backward.hpp"
int main (int argc, char *argv[])
{
using namespace backward;
// TraceResolver thisIsAWorkaround;
StackTrace st; st.load_here(32);
Printer p; p.print(st);
return 0;
}
some modules are not loaded:
Stack trace (most recent call last):
The specified module could not be found.
#4 Object "", at CCCCCCCCCCCCCCCC, in ??
The specified module could not be found.
#3 Object "", at CCCCCCCCCCCCCCCC, in ??
The specified module could not be found.
#2 Object "", at 00000059C1BBFAC0, in ??
The specified module could not be found.
#1 Object "", at 0000005900000000, in ??
#0 Source "D:\dev\projects\backtracetest\backward.hpp", line 1130, in backward::StackTraceImpl<backward::system_tag::windows_tag>::load_here
1127: RtlCaptureContext(ctx_);
1128: }
1129:
>1130: if (!thd_) {
1131: thd_ = GetCurrentThread();
1132: }
But if I create an unused instance of TraceResolver before creating Printer:
#include "backward.hpp"
int main (int argc, char *argv[])
{
using namespace backward;
TraceResolver thisIsAWorkaround;
StackTrace st; st.load_here(32);
Printer p; p.print(st);
return 0;
}
everything works as expected:
Stack trace (most recent call last):
#6 Object "", at 00007FF86DA27034, in BaseThreadInitThunk
#5 Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp", line 17, in mainCRTStartup
#4 Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 331, in __scrt_common_main
#3 Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 288, in __scrt_common_main_seh
#2 Source "d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 79, in invoke_main
#1 Source "D:\dev\projects\backtracetest\main.cpp", line 222, in main
219: using namespace backward;
220: TraceResolver thisIsAWorkaround;
221: StackTrace st; st.load_here(32);
> 222: Printer p; p.print(st);
223: return 0;
#0 Source "D:\dev\projects\backtracetest\backward.hpp", line 1130, in backward::StackTraceImpl<backward::system_tag::windows_tag>::load_here
1127: RtlCaptureContext(ctx_);
1128: }
1129:
>1130: if (!thd_) {
1131: thd_ = GetCurrentThread();
1132: }
I'm using Visual Studio 2019 community edition, 19.25.28614.0, and backward-cpp 1.5 from Conan.
Visual Studio 2022, msvc 19.30.30705, backward-cpp 1.6 ,too.
And for first example,it will print "Moudle Not Found".(Seem from WIN32 API)