willb (owner)

Revisions

gist: 215416 Download_button fork
public
Public Clone URL: git://gist.github.com/215416.git
Embed All Files: show embed
crashy.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby
 
# This code crashes ruby 1.8.6 in Fedora 11 and 12.
# It seems to work in 1.8.5 and 1.8.7.
 
module Frotz
  DICT = {
    'map' => 'MAP'
  }
end
 
def do_crashy
  result = Crashy.new
  yield result.args if block_given?
  result
end
 
class Crashy
  attr_reader :args
  def initialize
    @args = arg_struct
  end
 
  private
  def arg_struct
    @@prototype_args ||= gen_proto_args
    @@prototype_args.clone
  end
  
  def gen_proto_args
    proto_args = []
    
    def proto_args.declare(kind)
      # Any reference to Frotz causes ruby 1.8.6 in Fedora 11 and 12 to segfault
      # however, "d = ::Frotz::DICT" does not fail
      d = Frotz::DICT
      kind = d[kind] if d[kind]
      self << [kind]
    end
    
    proto_args
  end
end
 
cr = do_crashy do |args|
  args.declare "blah"
end
 
p cr