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.