summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorChris Seaton <chris.seaton@shopify.com>2022-06-14 16:08:36 +0100
committerAlan Wu <XrXr@users.noreply.github.com>2022-06-20 17:18:29 -0400
commit31b2cd38c5dcf4a0c51ca56ecdddf7461b8ac86c (patch)
treed282ecaade8561f335ea1cbb1cc0246909b897e8 /error.c
parent5ca2335802b281f9a38b1d9b73b146b94ed0eed3 (diff)
downloadruby-31b2cd38c5dcf4a0c51ca56ecdddf7461b8ac86c.tar.gz
Include JIT information in crash reports
Since enabling YJIT or MJIT drastically changes what could go wrong at runtime, it's good to be front and center about whether they are enabled when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the description printed when crashing can be different when a JIT is on. Introduce a new internal data global, `rb_dynamic_description`, and set it to be the same as `RUBY_DESCRIPTION` during initialization; use it when crashing. * version.c: Init_ruby_description(): Initialize and use `rb_dynamic_description`. * error.c: Change crash reports to use `rb_dynamic_description`. * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work for when we exit right after printing the description but that was deemed acceptable. * include/ruby/version.h: Talk about how JIT info is not in `ruby_description`. * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for crash description being different from `RUBY_DESCRIPTION`. * test/ruby/test_rubyoptions.rb: ditto Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
Diffstat (limited to 'error.c')
-rw-r--r--error.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/error.c b/error.c
index 35e797f5b9..d5721b2eca 100644
--- a/error.c
+++ b/error.c
@@ -82,7 +82,7 @@ static struct {
st_table *id2enum, *enum2id;
} warning_categories;
-extern const char ruby_description[];
+extern const char *rb_dynamic_description;
static const char *
rb_strerrno(int err)
@@ -730,7 +730,7 @@ bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
fputs("[BUG] ", out);
vsnprintf(buf, sizeof(buf), fmt, args);
fputs(buf, out);
- snprintf(buf, sizeof(buf), "\n%s\n\n", ruby_description);
+ snprintf(buf, sizeof(buf), "\n%s\n\n", rb_dynamic_description);
fputs(buf, out);
preface_dump(out);
}
@@ -866,7 +866,7 @@ rb_async_bug_errno(const char *mesg, int errno_arg)
write_or_abort(2, errno_str, strlen(errno_str));
}
WRITE_CONST(2, "\n\n");
- write_or_abort(2, ruby_description, strlen(ruby_description));
+ write_or_abort(2, rb_dynamic_description, strlen(rb_dynamic_description));
abort();
}
@@ -882,7 +882,7 @@ rb_assert_failure(const char *file, int line, const char *name, const char *expr
FILE *out = stderr;
fprintf(out, "Assertion Failed: %s:%d:", file, line);
if (name) fprintf(out, "%s:", name);
- fprintf(out, "%s\n%s\n\n", expr, ruby_description);
+ fprintf(out, "%s\n%s\n\n", expr, rb_dynamic_description);
preface_dump(out);
rb_vm_bugreport(NULL);
bug_report_end(out);