diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-09 08:31:28 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-09 08:31:28 +0000 |
commit | 2132fb9fd1fb8d32e5f1ae681fafbf295b91eac5 (patch) | |
tree | f3b231a3381a88dc086a19459ae745b6a82deec4 /eval.c | |
parent | f6d9f6fd2a7ad2f20472f3704ae7d4e810627c54 (diff) |
merge revision(s) 57415,57474: [Backport #13239]
eval.c: copy special exception
* eval.c (setup_exception): make unfrozen copy of special
exception before setting up a cause.
test_io.rb: separate a test
* test/ruby/test_io.rb (test_closed_stream_in_rescue): run in a
separated process.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -471,6 +471,17 @@ sysstack_error_p(VALUE exc) return exc == sysstack_error || (!SPECIAL_CONST_P(exc) && RBASIC_CLASS(exc) == rb_eSysStackError); } +static inline int +special_exception_p(rb_thread_t *th, VALUE exc) +{ + enum ruby_special_exceptions i; + const VALUE *exceptions = th->vm->special_exceptions; + for (i = 0; i < ruby_special_error_count; ++i) { + if (exceptions[i] == exc) return TRUE; + } + return FALSE; +} + static void setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) { @@ -488,6 +499,9 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) mesg = rb_exc_new(rb_eRuntimeError, 0, 0); nocause = 0; } + else if (special_exception_p(th, mesg)) { + mesg = ruby_vm_special_exception_copy(mesg); + } if (cause != Qundef) { mesg = exc_setup_cause(mesg, cause); } @@ -504,9 +518,6 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) if (sysstack_error_p(mesg)) { if (NIL_P(rb_attr_get(mesg, idBt))) { at = rb_vm_backtrace_object(); - if (mesg == sysstack_error) { - mesg = ruby_vm_sysstack_error_copy(); - } rb_ivar_set(mesg, idBt, at); rb_ivar_set(mesg, idBt_locations, at); } |