Merge pull request #4460 from roc-lang/crash

Crash
This commit is contained in:
Richard Feldman 2022-11-25 17:18:21 -05:00 committed by GitHub
commit 58fad36f9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 1247 additions and 455 deletions

View file

@ -58,12 +58,16 @@ pub unsafe extern "C" fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
}
#[no_mangle]
pub unsafe extern "C" fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
pub unsafe extern "C" fn roc_panic(msg: &RocStr, tag_id: u32) {
match tag_id {
0 => {
let slice = CStr::from_ptr(c_ptr as *const c_char);
let string = slice.to_str().unwrap();
eprintln!("Roc crashed with:\n\n\t{}\n", string);
eprintln!("Roc crashed with:\n\n\t{}\n", msg.as_str());
print_backtrace();
std::process::exit(1);
}
1 => {
eprintln!("The program crashed with:\n\n\t{}\n", msg.as_str());
print_backtrace();
std::process::exit(1);