ruby-changes:32685
From: usa <ko1@a...>
Date: Thu, 30 Jan 2014 20:04:23 +0900 (JST)
Subject: [ruby-changes:32685] usa:r44764 (ruby_1_9_3): merge revision(s) 43994, 44000: [Backport #9205]
usa 2014-01-30 20:04:17 +0900 (Thu, 30 Jan 2014) New Revision: 44764 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44764 Log: merge revision(s) 43994,44000: [Backport #9205] * gc.c (finalize_deferred): flush all deferred finalizers while other finalizers can get ready to run newly by lazy sweep. [ruby-core:58833] [Bug #9205] Modified directories: branches/ruby_1_9_3/ Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/gc.c branches/ruby_1_9_3/ruby_atomic.h branches/ruby_1_9_3/test/ruby/test_gc.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 44763) +++ ruby_1_9_3/ChangeLog (revision 44764) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1 +Thu Jan 30 19:54:16 2014 Nobuyoshi Nakada <nobu@r...> + + * gc.c (finalize_deferred): flush all deferred finalizers while other + finalizers can get ready to run newly by lazy sweep. + [ruby-core:58833] [Bug #9205] + Thu Jan 30 19:08:00 2014 Nobuyoshi Nakada <nobu@r...> * gc.c (rb_gc_finalize_deferred, rb_objspace_call_finalizer): Index: ruby_1_9_3/ruby_atomic.h =================================================================== --- ruby_1_9_3/ruby_atomic.h (revision 44763) +++ ruby_1_9_3/ruby_atomic.h (revision 44764) @@ -19,6 +19,7 @@ typedef unsigned int rb_atomic_t; /* Any https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ruby_atomic.h#L19 # define ATOMIC_SIZE_INC(var) __sync_fetch_and_add(&(var), 1) # define ATOMIC_SIZE_DEC(var) __sync_fetch_and_sub(&(var), 1) # define ATOMIC_SIZE_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) +# define ATOMIC_PTR_EXCHANGE(var, val) __atomic_exchange_n(&(var), (val), __ATOMIC_SEQ_CST) #elif defined _WIN32 #if defined _MSC_VER && _MSC_VER > 1200 @@ -112,4 +113,10 @@ atomic_size_exchange(size_t *ptr, size_t https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ruby_atomic.h#L113 } #endif +#ifndef ATOMIC_PTR_EXCHANGE +# if SIZEOF_VOIDP == SIZEOF_SIZE_T +# define ATOMIC_PTR_EXCHANGE(var, val) (void *)ATOMIC_SIZE_EXCHANGE(*(size_t *)&(var), (size_t)(val)) +# endif +#endif + #endif /* RUBY_ATOMIC_H */ Index: ruby_1_9_3/gc.c =================================================================== --- ruby_1_9_3/gc.c (revision 44763) +++ ruby_1_9_3/gc.c (revision 44764) @@ -3044,10 +3044,9 @@ run_final(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/gc.c#L3044 static void finalize_deferred(rb_objspace_t *objspace) { - RVALUE *p = deferred_final_list; - deferred_final_list = 0; + RVALUE *p; - if (p) { + while ((p = ATOMIC_PTR_EXCHANGE(deferred_final_list, 0)) != 0) { finalize_list(objspace, p); } } Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 44763) +++ ruby_1_9_3/version.h (revision 44764) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1 #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 506 +#define RUBY_PATCHLEVEL 507 #define RUBY_RELEASE_DATE "2014-01-30" #define RUBY_RELEASE_YEAR 2014 Index: ruby_1_9_3/test/ruby/test_gc.rb =================================================================== --- ruby_1_9_3/test/ruby/test_gc.rb (revision 44763) +++ ruby_1_9_3/test/ruby/test_gc.rb (revision 44764) @@ -112,4 +112,18 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_gc.rb#L112 ObjectSpace.define_finalizer(Thread.main) { p 'finalize' } EOS end + + def test_sweep_in_finalizer + bug9205 = '[ruby-core:58833] [Bug #9205]' + 2.times do + assert_ruby_status([], <<-'end;', bug9205) + raise_proc = proc do |id| + GC.start + end + 1000.times do + ObjectSpace.define_finalizer(Object.new, raise_proc) + end + end; + end + end end Property changes on: ruby_1_9_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r43994,44000 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/