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
  a = 1
  p Kernel.eval("local_variables",binding)
end

puts "while"
while true
  a = 1
  p Kernel.eval("local_variables",binding)
  break
end

puts "lambda"
lambda {
  a=1
  p Kernel.eval("local_variables",binding)
}.call


But I get a segfault with

for i in 1..100
  a = 1
  p Kernel.eval("local_variables",binding)
  break
end

But you can try,

for i in 1..100
  a = 1
  r = Kernel.eval("local_variables",binding)
  p r.length # => 4, but should be 3
  p r[1..-1] # => [:i,:a,:r]
  p r.first.class # => Symbol
  p r.first.object_id # => 4087
  p r.first  # segfault
  break
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
 p Kernel.eval("local_variables") # this works
 break
end