summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-05-30 08:20:02 -0700
committerGitHub <noreply@github.com>2023-05-30 11:20:02 -0400
commit1f74e25c3bb9398c2b47fde771e35293e2c29ad9 (patch)
treeef316700ff7ca5bb70350cbefa4eafc3fb3fbd78
parent4bbeed61346d6016e2d72818e8068bedcb9f006d (diff)
YJIT: Force showing a backtrace on panic (#7869)
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
-rw-r--r--yjit/src/yjit.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/yjit/src/yjit.rs b/yjit/src/yjit.rs
index 3201af6982..08440d7076 100644
--- a/yjit/src/yjit.rs
+++ b/yjit/src/yjit.rs
@@ -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); }