-
-
Save gabrielg/ec12e41efda564ccac7a 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 | |
def recurse; recurse; end | |
begin | |
puts(*(0...140000)) | |
rescue Exception => e | |
puts "caught exception: #{e.inspect}" | |
end | |
begin | |
eval "raise RuntimeError, 'kapow'" | |
rescue Exception => e | |
puts "caught exception: #{e.inspect}" | |
end | |
begin | |
eval "recurse" | |
rescue Exception => e | |
puts "caught exception: #{e.inspect}" | |
end | |
begin | |
eval "puts(*(0...140000))" | |
rescue Exception => e | |
puts "caught exception: #{e.inspect}" | |
end | |
begin | |
eval "<COMPLETELY INVALID SYNTAX>" | |
rescue Exception => e | |
puts "caught exception: #{e.inspect}" | |
end | |
begin | |
arg_string = (0...140000).to_a.join(", ") | |
eval "puts(#{arg_string})" | |
rescue Exception => e | |
puts "caught exception: #{e.inspect}" | |
end | |
puts "Never reached." |
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
gabriel@last:~/Code/ruby$ ruby -v | |
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0] | |
gabriel@last:~/Code/ruby$ ruby exceptions_in_eval.rb | |
caught exception: #<SystemStackError: stack level too deep> | |
caught exception: #<RuntimeError: kapow> | |
caught exception: #<SystemStackError: stack level too deep> | |
caught exception: #<SystemStackError: stack level too deep> | |
caught exception: #<SyntaxError: (eval):1: syntax error, unexpected '<' | |
<COMPLETELY INVALID SYNTAX> | |
^ | |
(eval):1: syntax error, unexpected $end | |
<COMPLETELY INVALID SYNTAX> | |
^> | |
(eval):0: stack level too deep (SystemStackError) | |
gabriel@last:~/Code/ruby$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment