Irb bug with $SAFE?


(Philip Mak) #1

I was just playing with $SAFE in irb and it said “Maybe IRB bug!!” at
the end. Does anyone know what I’m doing wrong? I’m trying to learn
how $SAFE works by experimenting. Should I just do this in "ruby"
instead of “irb” instead?

[shoujoai@lina rb]$ irb
irb(main):001:0> $SAFE
0
irb(main):002:0> $SAFE = 1
1
irb(main):003:0> $SAFE = 2
2
irb(main):004:0> $SAFE = 3
SecurityError: Insecure operation - eval
from /usr/local/lib/ruby/1.6/irb/workspace.rb:80:in eval' from /usr/local/lib/ruby/1.6/irb/workspace.rb:80:inevaluate’
from /usr/local/lib/ruby/1.6/irb/context.rb:126:in _=' from /usr/local/lib/ruby/1.6/irb.rb:141:ineval_input’
from /usr/local/lib/ruby/1.6/irb.rb:141:in trace_in' from /usr/local/lib/ruby/1.6/irb.rb:141:ineval_input’
from /usr/local/lib/ruby/1.6/irb.rb:138:in signal_status' from /usr/local/lib/ruby/1.6/irb.rb:138:ineval_input’
from /usr/local/lib/ruby/1.6/irb.rb:136:in each_top_level_statement' from /usr/local/lib/ruby/1.6/irb/ruby-lex.rb:243:inloop’
from /usr/local/lib/ruby/1.6/irb/ruby-lex.rb:243:in each_top_level_statement' from /usr/local/lib/ruby/1.6/irb/ruby-lex.rb:216:incatch’
from /usr/local/lib/ruby/1.6/irb/ruby-lex.rb:216:in each_top_level_statement' from /usr/local/lib/ruby/1.6/irb.rb:136:ineval_input’
from /usr/local/lib/ruby/1.6/irb.rb:68:in start' from /usr/local/lib/ruby/1.6/irb.rb:67:incatch’
from /usr/local/lib/ruby/1.6/irb.rb:67:in `start’
from /usr/local/bin/irb:13Maybe IRB bug!!


(Tobi Reif) #2

Philip Mak wrote:

I was just playing with $SAFE in irb and it said “Maybe IRB bug!!” at
the end. Does anyone know what I’m doing wrong? I’m trying to learn
how $SAFE works by experimenting. Should I just do this in "ruby"
instead of “irb” instead?

IIRC: Yes, because irb uses eval.

Tobi

···


http://www.pinkjuice.com/


(Kent Dahl) #3

Tobias Reif wrote:

Philip Mak wrote:

I was just playing with $SAFE in irb and it said “Maybe IRB bug!!” at
the end. Does anyone know what I’m doing wrong? I’m trying to learn
how $SAFE works by experimenting. Should I just do this in "ruby"
instead of “irb” instead?

IIRC: Yes, because irb uses eval.

Or spawn of threads that set the $SAFE level and call the methods you
want to test.

Not for the faint hearted, but nice for learning some $SAFE (and thread)
stuff. Just remember to set abort_on_exception for threads, wrap them in
begin…rescue…end blocks and use puts statements like mad :slight_smile:

···


([ Kent Dahl ]/)_ ~ [ http://www.stud.ntnu.no/~kentda/ ]/~
))_student
/(( _d L b_/ NTNU - graduate engineering - 4. year )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)