backtrace-rs
backtrace-rs copied to clipboard
Reduce panics in dbghelp
According to the docs for resolve
:
The closure may not be called if resolution could not be performed This function strives to never panic.
So we should ideally not panic and instead simply return without calling the closure. Therefore, I've changed the panicky FFI calls to instead simply return.
I also replaced our custom UTF-16 to UTF-8 converter with a call to WideCharToMultiByte
. This function already has the semantics we want and doesn't include panicking code.
These changes should have a small but notable effect on binary size.
Code size changes for a hello-world Rust program linked with libstd with backtrace:
On platform windows-latest
:
- Original binary size: 141,312 B
- Updated binary size: 138,752 B
- Difference: -2,560 B (-1.81%)