mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
31b2cd38c5
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>
28 lines
845 B
Ruby
28 lines
845 B
Ruby
# frozen_string_literal: false
|
|
require 'test/unit'
|
|
require 'tmpdir'
|
|
|
|
class TestBugReporter < Test::Unit::TestCase
|
|
def test_bug_reporter_add
|
|
omit if ENV['RUBY_ON_BUG']
|
|
|
|
description = RUBY_DESCRIPTION
|
|
expected_stderr = [
|
|
:*,
|
|
/\[BUG\]\sSegmentation\sfault.*\n/,
|
|
/#{ Regexp.quote(description) }\n\n/,
|
|
:*,
|
|
/Sample bug reporter: 12345/,
|
|
:*
|
|
]
|
|
tmpdir = Dir.mktmpdir
|
|
|
|
no_core = "Process.setrlimit(Process::RLIMIT_CORE, 0); " if defined?(Process.setrlimit) && defined?(Process::RLIMIT_CORE)
|
|
args = ["--disable-gems", "-r-test-/bug_reporter",
|
|
"-C", tmpdir]
|
|
stdin = "#{no_core}register_sample_bug_reporter(12345); Process.kill :SEGV, $$"
|
|
assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT")
|
|
ensure
|
|
FileUtils.rm_rf(tmpdir) if tmpdir
|
|
end
|
|
end
|