-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Ruby has this particular string in it's own test suite:
filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8This will cause ruru to panic:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err`
value: Utf8Error { valid_up_to: 0, error_len: Some(1) }', /checkout/src/libcore/result.rs:906:4
I've tried wrapping it in a thread but that failed.
In Rust, panic is safe and per-thread. The boundaries between threads serve as a firewall for panic;
- Programming Rust by Jim Blandy, Jason Orendorff
I then found Rust's std::panic::catch_unwind which according to the original RFC is meant to handle such panics from C method calls. The catch_unwind doc has this note:
Note that this function may not catch all panics in Rust. A panic in Rust is not always implemented via unwinding, but can be implemented by aborting the process as well. This function only catches unwinding panics, not those that abort the process.
I have thus far been unable to catch the panic from this and looking up the error Utf8Error it would seem that that is a side effect of the kind of methods used from libruby for RString and that error isn't written in ruru.