-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better backtrace when Rust panics #117
Comments
Right now I don't think that's possible - if you wanted to look into it I think the best path would be using this crate: https://crates.io/crates/backtrace to add the backtrace information to the error message in the panic handler: Line 24 in cae584c
|
I exported that function: pub fn init_rust_panic_hook() {
panic::set_hook(Box::new(|_| {
let bt = Backtrace::new();
println!("Rust custom panic hook: {:?}", bt);
}));
} and I'm initializing it in Ocaml: let () = RustHelpers.init_rust_panic_hook () but when the panic happens this is what I get:
no dune/ocaml output past the panic, interesting o.o |
removing the use of my theory is that the panic raised by OCaml is also caught by my hook, and it doesn't let OCaml recover |
adding a backtrace to an error type (with thiserror) also creates issues. I've posted on ocamlforum as well: https://discuss.ocaml.org/t/catching-panics-in-rust/11730 |
Hi, I ran into a similar issue where I was trying to do something similar, but with ocaml-interop. I'm not exactly sure why I didn't hit any issues, since I was able to convert panics into exceptions (including backtraces) without any trouble; here's an expect test which demonstrates the code; if you change |
Currently Rust panicking can be caught as an exception in OCaml, and converted as a string it looks somewhat like that:
but there is no backtrace, and not much information about the panic. Is it possible to obtain better backtraces?
The text was updated successfully, but these errors were encountered: