Set_trace_func dumps core (2)


#1

e$B0J2<$N$h$&$K$9$k$He(Bcoree$B$rEG$-$^$9!#e(B

% cat segv.rb
class Binding
def eval str, *a
Kernel.eval str, self, *a
end
end

class Foo
def m1
callcc do |*|
x = lambda do |e, f, l, m, b, c|
set_trace_func nil
yield b
end
y = lambda do |e, *|
set_trace_func x if e == “return”
end
set_trace_func y
return
end
end

def m2
m1 do |b|
p [self, b.eval(“self”), eval(“self”, b)]
end
end
end

eval “Foo.new.m2.foo”

% gdb --args ruby-1.8 -v segv.rb
GNU gdb 6.1-20040303 (Apple version gdb-413) (Wed May 18 10:17:02 GMT
2005)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for
details.
This GDB was configured as “powerpc-apple-darwin”…Reading symbols for
shared libraries … done

(gdb) run
Starting program: /usr/local/bin/ruby-1.8 -v segv.rb
Reading symbols for shared libraries …+. done
ruby 1.8.4 (2006-05-11) [powerpc-darwin8.6.0]
[#Foo:0x25a30, #Foo:0x25a30, #Foo:0x25a30]

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
Cannot access memory at address 0x0
Cannot access memory at address 0x0
Cannot access memory at address 0x0
#1 0x002254e8 in rb_call0 (klass=Cannot access memory at address 0x0
154520, recv=154160, id=10065, oid=Cannot access memory at address 0x0
Cannot access memory at address 0x0
10065, argc=0, argv=0x0, body=0x25d28, flags=0) at
…/ruby-1.8/eval.c:5920
#2 0x00225838 in rb_call (klass=154520, recv=154160, mid=10065, argc=0,
argv=0x0, scope=0) at …/ruby-1.8/eval.c:6001
#3 0x00222984 in rb_eval (self=219620, n=0x25d28) at
…/ruby-1.8/eval.c:3430
#4 0x002227b4 in rb_eval (self=219620, n=0x25d28) at
…/ruby-1.8/eval.c:3424
#5 0x002315ec in eval (self=219620, src=154400, scope=4, file=0x2a031c
“(eval)”, line=1) at …/ruby-1.8/eval.c:6395
#6 0x00231a5c in rb_f_eval (argc=2824376, argv=0x25d28, self=2822604)
at …/ruby-1.8/eval.c:6507
#7 0x00224e00 in rb_call0 (klass=224400, recv=219620, id=3913,
oid=3913, argc=1, argv=0xbfffe000, body=0x35264, flags=2) at
…/ruby-1.8/eval.c:5771
#8 0x00225838 in rb_call (klass=224400, recv=219620, mid=3913, argc=1,
argv=0xbfffe000, scope=1) at …/ruby-1.8/eval.c:6001
#9 0x00222bbc in rb_eval (self=0, n=0x25d28) at …/ruby-1.8/eval.c:3445
#10 0x00232d50 in ruby_exec_internal () at …/ruby-1.8/eval.c:1590
#11 0x00232d9c in ruby_exec () at …/ruby-1.8/eval.c:1610
#12 0x00232de4 in ruby_run () at …/ruby-1.8/eval.c:1620
#13 0x00002ce8 in main (argc=3, argv=0xbfffec24, envp=0x25a30) at
…/ruby-1.8/main.c:46
(gdb)