bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.68k stars 467 forks source link

don't crash when `_Unwind_Backtrace` fails #270

Closed DoDoENT closed 1 year ago

DoDoENT commented 1 year ago

In release build without symbols and frame pointers, _Unwind_Backtrace can be a no-op, not invoking the callback even a single time.

This then keeps the _index at -1, so after casting into size_t and attempting to allocate vector with that size, app crashes (vector::resize to MAX_UINT does not work 😛 ).

The issue didn't happen when using the backtrace backends - it correctly returns the empty stack trace in that case.

This patch ensures the same behavior also when using unwind.

bombela commented 1 year ago

Thank you!

This was a shameful oversight.