From 527be1b25a3192fffa143ef4bb520c9812e8324d Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 30 Aug 2011 13:39:31 +0000 Subject: [PATCH] * test/dl/test_callback.rb (test_callback_with_string): prevents temporary string from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/dl/test_callback.rb | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 906f1f8581..58e4fcd1d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Aug 30 22:34:45 2011 CHIKANAGA Tomoyuki + + * test/dl/test_callback.rb (test_callback_with_string): prevents + temporary string from GC. + Tue Aug 30 22:25:38 2011 NAKAMURA Usaku * vm_insnhelper.c (vm_call_cfunc): revert r33112. RB_GC_GUARD macro diff --git a/test/dl/test_callback.rb b/test/dl/test_callback.rb index ed3be661e7..fb24ff0ca5 100644 --- a/test/dl/test_callback.rb +++ b/test/dl/test_callback.rb @@ -48,8 +48,11 @@ module DL func = CFunc.new(addr, TYPE_VOID, 'test') f = Function.new(func, [TYPE_VOIDP]) - f.call(dlwrap('foo')) - assert_equal 'foo', called_with + # Don't remove local variable arg. + # This necessary to protect objects from GC. + arg = 'foo' + f.call(dlwrap(arg)) + assert_equal arg, called_with end def test_call_callback