Project

General

Profile

Bug #11692 ยป example2.rb

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

 
1
require 'json'
2

    
3
class Foo
4
  def to_json(*)
5
    JSON self
6
  end
7
end
8

    
9
Thread.new do
10
  JSON Foo.new
11
end
12

    
13
# Stack overflow exception occured and gc switched off
14

    
15
sleep 1
16

    
17
GC.start full_mark: true, immediate_sweep: true
18

    
19
if ObjectSpace.each_object(Thread).count > 1
20
  raise 'Should be only one thread after GC'
21
else
22
  puts 'All good'
23
end