backtrace-rs icon indicating copy to clipboard operation
backtrace-rs copied to clipboard

Reduce panics in dbghelp

Open ChrisDenton opened this issue 10 months ago • 1 comments

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.

ChrisDenton avatar Apr 02 '24 12:04 ChrisDenton

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%)

github-actions[bot] avatar Apr 02 '24 12:04 github-actions[bot]