orling / Poppy

Poppy is a stack tracing and performance measurement library for C++
MIT License
59 stars 13 forks source link

Stack trace is incorrect if instrumented function called during unwind #5

Open raptorswing opened 7 years ago

raptorswing commented 7 years ago

Thanks for this code, it is helpful.

As you know, when an exception is thrown the stack is unwound. As that is happening, objects are destructed and their destructors are called. If one of these destructors calls a function instrumented with STACK, that function will be incorrectly added to the stack trace.

I worked around this by adding the following at the beginning of Scope's constructor:

// Don't add new stacks while unwinding when destructors, etc. may call lots of instrumented functions
if (std::uncaught_exception())
    return;