summaryrefslogtreecommitdiff
path: root/test/ruby/test_time.rb
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-19 08:19:13 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-19 08:19:13 +0000
commite0a0edf548ec518651f2571ac02a2716855b50d8 (patch)
tree2e53658ce0d921abe076c98a0b439a25e77c90ce /test/ruby/test_time.rb
parent5f00b99975099224a19cf85beb8c51ed8b1cd96c (diff)
time.c: freeze and preserve marshal-loaded time zone
We need to prevent vtm.zone from pointing to a GC-ed string buffer. The rb_copy_generic_ivar call misses it because get_attr deleted it. Thanks to nobu for the rb_str_new_frozen suggestion. * time.c (time_mload): freeze and preserve marshal-loaded time zone * test/ruby/test_time.rb: add test for GC on loaded object [Bug #9652] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_time.rb')
-rw-r--r--test/ruby/test_time.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index c8b9e8f175..cb0859473f 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -310,6 +310,21 @@ class TestTime < Test::Unit::TestCase
end
end
+ def test_marshal_zone_gc
+ assert_separately(%w(--disable-gems), <<-'end;')
+ ENV["TZ"] = "Japan"
+ s = Marshal.dump(Time.now)
+ t = Marshal.load(s)
+ n = 0
+ done = 1000000
+ while t.zone.dup == "JST" && n < done
+ n += 1
+ end
+ assert_equal n, done, "Bug #9652"
+ assert_equal "JST", t.zone, "Bug #9652"
+ end;
+ end
+
def test_marshal_to_s
t1 = Time.new(2011,11,8, 0,42,25, 9*3600)
t2 = Time.at(Marshal.load(Marshal.dump(t1)))