Hi,

My ruby runtime is "ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-
linux]"

Kernel eval works for these cases:

puts "2 times"
1.times do
=A0a =3D 1
=A0p Kernel.eval("local_variables",binding)
end

puts "while"
while true
=A0a =3D 1
=A0p Kernel.eval("local_variables",binding)
=A0break
end

puts "lambda"
lambda {
=A0a=3D1
=A0p Kernel.eval("local_variables",binding)
}.call


But I get a segfault with

for i in 1..100
=A0a =3D 1
=A0p Kernel.eval("local_variables",binding)
=A0break
end

But you can try,

for i in 1..100
=A0a =3D 1
=A0r =3D Kernel.eval("local_variables",binding)
=A0p r.length # =3D> 4, but should be 3
=A0p r[1..-1] # =3D> [:i,:a,:r]
=A0p r.first.class # =3D> Symbol
=A0p r.first.object_id # =3D> 4087
=A0p r.first =A0# segfault
=A0break
end

And we see that there's an extraneous variable reported by evaluating
local_variables. The first element of the result seems an invalid
pointer?

for i in 1..100
=A0p Kernel.eval("local_variables") # this works
=A0break
end



--=20
blog: www.metacircus.com