is it normal to be kicked out of irb?

E

Emmanuel Oga

Is it normal to be kicked off of irb when a Fatal error occurs ? I was
kicked of of it while testing this (kicked off != code halt with an
exception):

$ irb
irb(main):001:0> def is_prime?(n); ("1" * n) !~ /^1?$|^(11+?)\1+$/ ;
rescue NoMemoryError; puts "ouch"; end
=> nil
irb(main):002:0> is_prime?(2)
=> true
irb(main):005:0> is_prime?(100000000)
ouch
=> nil
irb(main):006:0> is_prime?(1000000000)
[FATAL] failed to allocate memory
$

p.s.: is_prime? method taken from
http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/
 
R

Robert Dober

Is it normal to be kicked off of irb when a Fatal error occurs ? I was
kicked of of it while testing this (kicked off != code halt with an
exception):

$ irb
irb(main):001:0> def is_prime?(n); ("1" * n) !~ /^1?$|^(11+?)\1+$/ ;
rescue NoMemoryError; puts "ouch"; end
=> nil
irb(main):002:0> is_prime?(2)
=> true
irb(main):005:0> is_prime?(100000000)
ouch
=> nil
irb(main):006:0> is_prime?(1000000000)
[FATAL] failed to allocate memory
$

p.s.: is_prime? method taken from
http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/


It does not surprise me that IRB exits ungracefully in that case. BTW
it does not surprise me either that the backtracking regular
expression runs out of memory for such large numbers even if they are
even ;).

Cheers
Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top