jeremy-rifkin / cpptrace

Simple, portable, and self-contained stacktrace library for C++11 and newer
MIT License
701 stars 75 forks source link

StackWalk64 frame walking broken when using mingw gcc optimization #71

Closed HybridEidolon closed 8 months ago

HybridEidolon commented 10 months ago

I've found that if objects are compiled with gcc's optimization flags, StackWalk64 is unable to find most instruction pointers on the stack, often producing an empty trace. I don't have a good test case for this unfortunately.

My use case is with complete static linkage, but to my knowledge it is not using LTO.

This issue does not seem to affect mgwhelp, which also uses dbghelp's StackWalk64.

jeremy-rifkin commented 10 months ago

Thanks for the report, I will try to reproduce. What architecture are you on? Where did you get mingw from? Is CaptureStackBackTrace (or whatnot) affected (-DCPPTRACE_UNWIND_WITH_WINAPI=On on a fresh build)?

HybridEidolon commented 10 months ago

mingw-w64 from msys2, 13.2.0. this is the stock vcpkg configuration compiling for 32-bit windows. haven't tried the CaptureStackBackTrace method but will when I get a chance

jeremy-rifkin commented 10 months ago

I've not yet been able to reproduce. What vcpkg setup were you using? What output were you seeing?

jeremy-rifkin commented 8 months ago

I've investigated this locally and all seems to work well under StackWalk64. I'm going to close this for now but if the problem persists on your end I am happy to investigate further.