diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-16 09:44:01 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-12-16 14:55:59 +0900 |
commit | d2f04d332f2ff04f25202ed38e23de526a9aea46 (patch) | |
tree | 905bd8eeda8249a8b1338416703d1254555a5581 | |
parent | 1e80a208cc44cbbdd4e49d6146eea29cde5cd42a (diff) |
Kernel#abort without arguments should print error info
[Bug #16424]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2754
-rw-r--r-- | eval.c | 6 | ||||
-rw-r--r-- | process.c | 2 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 12 | ||||
-rw-r--r-- | vm_core.h | 1 |
4 files changed, 16 insertions, 5 deletions
@@ -477,7 +477,7 @@ rb_class_modify_check(VALUE klass) NORETURN(static void rb_longjmp(rb_execution_context_t *, int, volatile VALUE, VALUE)); static VALUE get_errinfo(void); -static VALUE get_ec_errinfo(const rb_execution_context_t *ec); +#define get_ec_errinfo(ec) rb_ec_get_errinfo(ec) static VALUE exc_setup_cause(VALUE exc, VALUE cause) @@ -1847,8 +1847,8 @@ errinfo_place(const rb_execution_context_t *ec) return 0; } -static VALUE -get_ec_errinfo(const rb_execution_context_t *ec) +VALUE +rb_ec_get_errinfo(const rb_execution_context_t *ec) { const VALUE *ptr = errinfo_place(ec); if (ptr) { @@ -4279,7 +4279,7 @@ rb_f_abort(int argc, const VALUE *argv) rb_check_arity(argc, 0, 1); if (argc == 0) { rb_execution_context_t *ec = GET_EC(); - VALUE errinfo = ec->errinfo; + VALUE errinfo = rb_ec_get_errinfo(ec); if (!NIL_P(errinfo)) { rb_ec_error_print(ec, errinfo); } diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 72120e4508..32b415c1b3 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1509,7 +1509,17 @@ class TestProcess < Test::Unit::TestCase def test_abort with_tmpchdir do s = run_in_child("abort") - assert_not_equal(0, s.exitstatus) + assert_not_predicate(s, :success?) + write_file("test-script", "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + STDERR.reopen(STDOUT) + begin + raise "[Bug #16424]" + rescue => e + abort + end + end; + assert_include(IO.popen([RUBY, "test-script"], &:read), "[Bug #16424]") end end @@ -1848,6 +1848,7 @@ void rb_threadptr_interrupt(rb_thread_t *th); void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th); void rb_threadptr_pending_interrupt_clear(rb_thread_t *th); void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v); +VALUE rb_ec_get_errinfo(const rb_execution_context_t *ec); void rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo); void rb_execution_context_update(const rb_execution_context_t *ec); void rb_execution_context_mark(const rb_execution_context_t *ec); |