Project

General

Profile

Actions

Bug #5104

closed

test_rinda.rb の GC保護もれ

Added by nagachika (Tomoyuki Chikanaga) over 13 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
-
Backport:
[ruby-dev:44253]

Description

make test-all TESTS="--gc-stress -vq rinda/test_rinda.rb -n test_remote_array_and_hash"
と GC.stress = true で rinda のテストを通すと環境によって以下のように失敗します。

Rinda::TupleSpaceProxyTest#test_remote_array_and_hash = 4.62 s = E

Finished tests in 4.626161s, 0.2162 tests/s, 0.0000 assertions/s.

  1. Error:
    test_remote_array_and_hash(Rinda::TupleSpaceProxyTest):
    NoMethodError: undefined method size' for nil:NilClass /home/chikanaga/opt/ruby-trunk/src/ruby/test/rinda/test_rinda.rb:542:in test_remote_array_and_hash'
    ../ruby/test/runner.rb:15:in `'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

これはおそらくテストが悪くて、DRbObject は渡されたオブジェクトへの参照を保持せず object_id だけ持つので
参照されるオブジェクトが GC されないようにしないといけないと思います。どうでしょうか。
以下のようにローカル変数に格納して保護すれば OK になりました。

diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index b69b63a..f113777 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -539,9 +539,11 @@ class TupleSpaceProxyTest < Test::Unit::TestCase
end

def test_remote_array_and_hash

  • @ts.write(DRbObject.new([1, 2, 3]))
  • ary = [1, 2, 3]
  • @ts.write(DRbObject.new(ary))
    assert_equal([1, 2, 3], @ts.take([1, 2, 3], 0))
  • @ts.write(DRbObject.new({'head' => 1, 'tail' => 2}))
  • hsh = {'head' => 1, 'tail' => 2}
  • @ts.write(DRbObject.new(hsh))
    assert_equal({'head' => 1, 'tail' => 2},
    @ts.take({'head' => 1, 'tail' => 2}, 0))
    end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0