willb (owner)

Revisions

  • eeed26 Will Be... Wed Oct 21 12:48:06 -0700 2009
  • 3a3e0d Will Be... Wed Oct 21 12:35:09 -0700 2009
  • ae7e21 Will Be... Wed Oct 21 12:33:02 -0700 2009
  • cb6c03 Will Be... Wed Oct 21 12:32:17 -0700 2009
  • 9552c7 willb Wed Oct 21 08:06:46 -0700 2009
  • bdead8 willb Tue Oct 20 12:44:36 -0700 2009
  • bbedc3 willb Tue Oct 20 12:43:43 -0700 2009
  • e88e64 willb Tue Oct 20 12:41:17 -0700 2009
  • e6fbdb willb Tue Oct 20 12:40:43 -0700 2009
  • de7f9c willb Tue Oct 20 12:38:28 -0700 2009
gist: 214544 Download_button fork
public
Public Clone URL: git://gist.github.com/214544.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
 
# Why does this crash 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