Project

General

Profile

Bug #11692 » example2.rb

Example with json - gazay (Alex Gaziev), 11/15/2015 05:21 PM

 
require 'json'

class Foo
def to_json(*)
JSON self
end
end

Thread.new do
JSON Foo.new
end

# Stack overflow exception occured and gc switched off

sleep 1

GC.start full_mark: true, immediate_sweep: true

if ObjectSpace.each_object(Thread).count > 1
raise 'Should be only one thread after GC'
else
puts 'All good'
end
(2-2/6)