Deadlock in eval when $SAFE>=4

M

Michael Witrant

The following code produces a deadlock:

$ cat test.rb
def foo bar = nil; end
Thread.new { $SAFE=4; eval("foo foo foo") }.value

$ ruby18 -v test.rb
ruby 1.8.1 (2003-12-25) [i686-linux]
test.rb:2:in `value': Thread(0x401d1900): deadlock (fatal)
from test.rb:2

It works well when $SAFE <= 3 or when the number of "foo" is <= 2.
 
R

Robert Klemme

Michael Witrant said:
The following code produces a deadlock:

$ cat test.rb
def foo bar = nil; end
Thread.new { $SAFE=4; eval("foo foo foo") }.value

$ ruby18 -v test.rb
ruby 1.8.1 (2003-12-25) [i686-linux]
test.rb:2:in `value': Thread(0x401d1900): deadlock (fatal)
from test.rb:2
Funny...

It works well when $SAFE <= 3 or when the number of "foo" is <= 2.

.... or when the string is syntactically correct:

Thread.new { $SAFE=4; eval("foo; foo; foo") }.value

robert
 
T

ts

R> .... or when the string is syntactically correct:

It want to send a message

warning: parenthesize argument(s) for future version

because it run with $SAFE >= 4, it can't write ==> this stop the compile
phase, which has set `rb_thread_critical = Qtrue'

When it want to call Thread#value, it call Thread#join and because

rb_thread_critical = Qtrue (it was not reset to Qfalse)

it give the error deadlock


Guy Decoux
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top