path: root/test/rinda
diff options
authorYusuke Endoh <>2020-10-17 15:17:55 +0900
committerYusuke Endoh <>2020-10-17 15:17:55 +0900
commit5c003b4bcd70b03012f6d2e322bd175efd226528 (patch)
tree2b42f026dcb637369ebdf48f11b642bf192694de /test/rinda
parentf6661f50854e0cdccb03ee516a21ce62adf6c802 (diff)
test/rinda/test_rinda.rb: Prevent a callback Proc from being GC'ed
According to the log of ac803ab55db50ef891e3680680620d01f28a759b, I found that a thread terminates silently due to "recycled object" of id2ref: ``` "/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:366:in `_id2ref'" "/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:366:in `to_obj'" "/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1528:in `to_obj'" "/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1847:in `to_obj'" "/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1136:in `method_missing'" "/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/test/rinda/test_rinda.rb:652:in `block in do_reply'" ``` I believe that this unintentional thread termination has caused intermittent timeout failure of `TestRingServer#test_do_reply`. The root cause of the "recycled object" issue is a bug of `TestRingServer#test_do_reply`. It creates a callback Proc object but does not hold the reference to the object: ``` callback = callback ``` The original "callback" object is GC'ed unintentionally. I could consistently reproduce this issue on my machine by adding `GC.stress = true` at the first of `_test_do_reply` method body. This change uses another local variable name, "callback_orig", to keep the original Proc object.
Diffstat (limited to 'test/rinda')
1 files changed, 2 insertions, 2 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index c20f06017fc..e247635104a 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -673,11 +673,11 @@ class TestRingServer < Test::Unit::TestCase
def _test_do_reply
called = nil
- callback = proc { |ts|
+ callback_orig = proc { |ts|
called = ts
- callback = callback
+ callback = callback_orig
@ts.write [:lookup_ring, callback]