Project

General

Profile

Bug #11692 ยป gc_threads_issue.rb

ebeigarts (Edgars Beigarts), 11/17/2015 07:53 PM

 
1
#!/usr/bin/env ruby
2

    
3
# $ ruby -v
4
# ruby 2.3.0dev (2015-11-17 trunk 52623) [x86_64-darwin15]
5
# ruby gc_threads_issue.rb
6
# stack level too deep
7
# GC major: 0, minor: 0
8
# GC major: 0, minor: 0
9
# GC major: 0, minor: 0
10
# Killed: 9 # <- gets stuck, so kill -9 is the only way to stop it
11

    
12
# $ ruby -v
13
# ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
14
#
15
# $ ruby gc_threads_issue.rb
16
# stack level too deep
17
# GC major: 1, minor: 0
18
# GC major: 1, minor: 0
19
# GC major: 1, minor: 0
20
# Killed: 9 # <- gets stuck, so kill -9 is the only way to stop it
21

    
22
# $ ruby -v
23
# ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
24
#
25
# ruby gc_threads_issue.rb
26
# stack level too deep
27
# GC major: 1, minor: 2
28
# GC major: 14, minor: 14
29
# GC major: 24, minor: 23
30
# Killed: 9 # <- gets stuck, so kill -9 is the only way to stop it
31

    
32

    
33
# $ ruby -v
34
# jruby 1.7.13 (1.9.3p392) 2014-06-24 43f133c on Java HotSpot(TM) 64-Bit Server VM 1.8.0_66-b17 [darwin-x86_64]
35
# Exception in thread "Ruby-0-Thread-1: gc_threads_issue.rb:42" java.lang.ArrayIndexOutOfBoundsException: -1
36
# GC major: , minor:
37
# GC major: , minor:
38
# GC major: , minor:
39
# GC major: , minor:
40
# GC major: , minor:
41
# GC major: , minor:
42
# GC major: , minor:
43

    
44
class Infinity
45
  def self.run
46
    1.times { run }
47
  end
48
end
49

    
50
Thread.new do
51
  loop do
52
    begin
53
      Infinity.run
54
    rescue Exception => e
55
      puts e.message
56
    end
57
    sleep 3
58
  end
59
end
60

    
61
Thread.new do
62
  loop do
63
    "A" * 1000
64
  end
65
end
66

    
67
7.times do
68
  GC.start
69
  puts "GC major: #{GC.stat[:major_gc_count]}, minor: #{GC.stat[:minor_gc_count]}"
70
  sleep 1
71
end