1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/bootstraptest/test_objectspace.rb
kosaki a119b9d146 * vm_core.h (typedef struct rb_vm_struct): create a new
'inhibit_thread_createion' field.
* thread.c (rb_thread_terminate_all): set inhibit_thread_creation.
* thread.c (thread_s_new): don't permit to create new thread
  if the VM is under destruction. Otherwise evil finalizer code
  can make SEGV. [Bug #4992][ruby-core:37858]

* bootstraptest/test_objectspace.rb: new test for this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 07:46:00 +00:00

46 lines
1.1 KiB
Ruby

assert_normal_exit %q{
eval("", TOPLEVEL_BINDING)
minobj = ObjectSpace.to_enum(:each_object).min_by {|a| a.object_id }
maxobj = ObjectSpace.to_enum(:each_object).max_by {|a| a.object_id }
(((minobj.object_id-100)..(minobj.object_id+100))+
((maxobj.object_id-100)..(maxobj.object_id+100))).each {|id|
begin
o = ObjectSpace._id2ref(id)
rescue RangeError
next
end
o.inspect if defined?(o.inspect)
}
}, '[ruby-dev:31911]'
assert_normal_exit %q{
ary = (1..10).to_a
ary.permutation(2) {|x|
if x == [1,2]
ObjectSpace.each_object(String) {|s|
s.clear if !s.frozen? && (s.length == 40 || s.length == 80)
}
end
}
}, '[ruby-dev:31982]'
assert_normal_exit %q{
ary = (1..100).to_a
ary.permutation(2) {|x|
if x == [1,2]
ObjectSpace.each_object(Array) {|o| o.clear if o == ary && o.object_id != ary.object_id }
end
}
}, '[ruby-dev:31985]'
assert_normal_exit %q{
ObjectSpace.define_finalizer("") do
Mutex.new.lock
end
}, '[ruby-dev:44049]'
assert_normal_exit %q{
ObjectSpace.define_finalizer("") do
Thread.new {}
end
}, '[ruby-core:37858]'