YJIT: Force showing a backtrace on panic (#7869)

This commit is contained in:
Takashi Kokubun 2023-05-30 08:20:02 -07:00 committed by GitHub
parent 4bbeed6134
commit 1f74e25c3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-05-30 15:20:29 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>

View File

@ -87,6 +87,7 @@ pub extern "C" fn rb_yjit_init_rust() {
/// In case we want to start doing fancier exception handling with panic=unwind,
/// we can revisit this later. For now, this helps to get us good bug reports.
fn rb_bug_panic_hook() {
use std::env;
use std::panic;
use std::io::{stderr, Write};
@ -97,6 +98,8 @@ fn rb_bug_panic_hook() {
// Not using `eprintln` to avoid double panic.
let _ = stderr().write_all(b"ruby: YJIT has panicked. More info to follow...\n");
// Always show a Rust backtrace.
env::set_var("RUST_BACKTRACE", "1");
previous_hook(panic_info);
unsafe { rb_bug(b"YJIT panicked\0".as_ref().as_ptr() as *const raw::c_char); }