Is there any way to get the stacktrace when using the panic::set_hook
?
I am in the unfortunate position I cannot use RUSTC_BACKTRACE env variable to understand what is causing a panic
. My initial idea is to use the panic::set_hook
to handle the situation and retrieve the information in a custom way. However, I just realized that using PanicInfo
I only get the location of the single line causing the panic
. And this is mostly useless when this comes from an unwrap
ping instance.
Are you looking for the backtrace crate? This is essentially what RUSTC_BACKTRACE
or failure
would use under the hood, and it gives you a nice programmatic way of creating and inspecting a backtrace.
1 Like
Perfect, thanks!
I was not sure this was the actual crate to do that -- the 0.2 version was suspicious.
I am curious on what made you think that?
If you are asking why I was unsure about that crate, it is just because in a usual situation we have an integrated stacktrace dumping capability, and I (wrongly) expected to be based on a pretty stable API.
If you are asking why I cannot use the default RUST_BACKTRACE env variable, it is because I am doing something related to DLL injection on Windows (LD_PRELOAD, I miss you so much...), and I needed to use the MessageBoxA
to get the cause of a panic.