diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | gc.h | 2 | ||||
-rw-r--r-- | test/ruby/test_thread.rb | 11 | ||||
-rw-r--r-- | vm.c | 2 |
5 files changed, 20 insertions, 4 deletions
@@ -1,3 +1,10 @@ +Fri Feb 11 19:45:26 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * eval.c (ruby_cleanup): use rb_ary_free to free internal object. + + * gc.h (RUBY_FREE_UNLESS_NULL): get rid of double free. + [ruby-core:35192] + Fri Feb 11 16:57:03 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> * test/ruby/test_transcode.rb (test_from_cp50221): fix wrong @@ -170,7 +170,7 @@ ruby_cleanup(volatile int ex) for (i=RARRAY_LEN(ary) - 1; i>=0; i--) { ((void(*)(rb_vm_t*))RARRAY_PTR(ary)[i])(vm); } - rb_ary_clear(ary); + rb_ary_free(ary); #if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1 switch (ex) { @@ -58,7 +58,7 @@ rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr) #endif #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);} -#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);} +#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;} #if STACK_GROW_DIRECTION > 0 # define STACK_UPPER(x, a, b) (a) diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 4e53b7fa86..4089eb67a4 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -384,7 +384,7 @@ class TestThread < Test::Unit::TestCase end INPUT - assert_in_out_err(%w(--disable-gems -d), <<-INPUT, %w(false 2), /.+/) + assert_in_out_err(%w(--disable-gems -d), <<-INPUT, %w(false 2), %r".+") p Thread.abort_on_exception begin Thread.new { raise } @@ -577,6 +577,15 @@ class TestThread < Test::Unit::TestCase assert_nothing_raised {arr.hash} assert(obj[:visited]) end + + def test_thread_instance_variable + bug4389 = '[ruby-core:35192]' + assert_in_out_err([], <<-INPUT, %w(), [], bug4389) + class << Thread.current + @data = :data + end + INPUT + end end class TestThreadGroup < Test::Unit::TestCase @@ -230,7 +230,7 @@ env_free(void * const ptr) { RUBY_FREE_ENTER("env"); if (ptr) { - const rb_env_t * const env = ptr; + rb_env_t *const env = ptr; RUBY_FREE_UNLESS_NULL(env->env); ruby_xfree(ptr); } |