mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eval.c: determine exit status and signal before finalization
* eval.c (ruby_cleanup): determine exit status and signal to terminate before finalization, to get rid of access destroyed T_DATA execption object. [ruby-core:58643] [Bug #9167] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
520f0fec95
commit
04ca48fc38
4 changed files with 58 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Sat Nov 30 17:46:35 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (ruby_cleanup): determine exit status and signal to terminate
|
||||||
|
before finalization, to get rid of access destroyed T_DATA execption
|
||||||
|
object. [ruby-core:58643] [Bug #9167]
|
||||||
|
|
||||||
Sat Nov 30 16:25:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Nov 30 16:25:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* enumerator.c (enumerator_with_index): should not store local variable
|
* enumerator.c (enumerator_with_index): should not store local variable
|
||||||
|
|
13
eval.c
13
eval.c
|
@ -192,12 +192,6 @@ ruby_cleanup(volatile int ex)
|
||||||
}
|
}
|
||||||
th->errinfo = errs[1];
|
th->errinfo = errs[1];
|
||||||
ex = error_handle(ex);
|
ex = error_handle(ex);
|
||||||
ruby_finalize_1();
|
|
||||||
|
|
||||||
/* unlock again if finalizer took mutexes. */
|
|
||||||
rb_threadptr_unlock_all_locking_mutexes(GET_THREAD());
|
|
||||||
POP_TAG();
|
|
||||||
rb_thread_stop_timer_thread(1);
|
|
||||||
|
|
||||||
#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
|
#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
|
||||||
switch (ex) {
|
switch (ex) {
|
||||||
|
@ -232,6 +226,13 @@ ruby_cleanup(volatile int ex)
|
||||||
ex = EXIT_FAILURE;
|
ex = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ruby_finalize_1();
|
||||||
|
|
||||||
|
/* unlock again if finalizer took mutexes. */
|
||||||
|
rb_threadptr_unlock_all_locking_mutexes(GET_THREAD());
|
||||||
|
POP_TAG();
|
||||||
|
rb_thread_stop_timer_thread(1);
|
||||||
ruby_vm_destruct(GET_VM());
|
ruby_vm_destruct(GET_VM());
|
||||||
if (state) ruby_default_signal(state);
|
if (state) ruby_default_signal(state);
|
||||||
|
|
||||||
|
|
31
ext/-test-/exception/dataerror.c
Normal file
31
ext/-test-/exception/dataerror.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include <ruby/ruby.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
dataerror_mark(void *ptr)
|
||||||
|
{
|
||||||
|
rb_gc_mark((VALUE)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dataerror_free(void *ptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static const rb_data_type_t dataerror_type = {
|
||||||
|
"Bug #9167",
|
||||||
|
{dataerror_mark, dataerror_free},
|
||||||
|
};
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
dataerror_alloc(VALUE klass)
|
||||||
|
{
|
||||||
|
VALUE n = rb_str_new_cstr("[Bug #9167] error");
|
||||||
|
return TypedData_Wrap_Struct(klass, &dataerror_type, (void *)n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Init_dataerror(VALUE klass)
|
||||||
|
{
|
||||||
|
VALUE rb_eDataErr = rb_define_class_under(klass, "DataError", rb_eStandardError);
|
||||||
|
rb_define_alloc_func(rb_eDataErr, dataerror_alloc);
|
||||||
|
}
|
14
test/-ext-/exception/test_data_error.rb
Normal file
14
test/-ext-/exception/test_data_error.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
require 'test/unit'
|
||||||
|
require_relative '../../ruby/envutil'
|
||||||
|
|
||||||
|
module Bug
|
||||||
|
class TestException < Test::Unit::TestCase
|
||||||
|
def test_cleanup_data_error
|
||||||
|
bug9167 = '[ruby-core:58643] [Bug #9167]'
|
||||||
|
assert_normal_exit(<<-'end;', bug9167) # do
|
||||||
|
require '-test-/exception'
|
||||||
|
raise Bug::Exception::DataError, "Error"
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue