Created
October 21, 2009 20:03
-
-
Save willb/215416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment