>>>>> "S" == Sean Russell <ser / efn.org> writes:

S> ts wrote:
>> Well, not really sure but the problem seems to be with @prev (instance
>> variable of Node ?). The stack level is too deep when ruby try to mark
>> the object. Actually ruby try to detect this problem only when it run
>> rb_call0() and not when it try to mark an object.

S> I'm sorry, but how did you determine this?  I know of profile, but is there 
S> a trace option for Ruby?

pigeon% gdb ruby
GNU gdb 5.0.90-cvs (MI_OUT)
Copyright 2001 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 "i686-pc-linux-gnu"...
(gdb) r bench.rb
Starting program: /usr/local/bin/ruby bench.rb
                          user     system      total        real
parsing file        241.610000   2.350000 243.960000 (243.955870)
Document.new          3.840000   0.010000   3.850000 (  3.859674)
new element           3.440000   0.000000   3.440000 (  3.442063)
add element         
Program received signal SIGSEGV, Segmentation fault.
0x08066c2a in rb_gc_mark (ptr=0x4027ef20) at gc.c:442
442     }
(gdb) bt
#0  0x08066c2a in rb_gc_mark (ptr=0x4027ef20) at gc.c:442
#1  0x08066b25 in mark_entry (key=10202, value=1076358944) at gc.c:405
#2  0x0809de54 in st_foreach (table=0x838b8d8, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#3  0x08066b49 in rb_mark_tbl (tbl=0x838b8d8) at gc.c:414
#4  0x08066f7b in rb_gc_mark (ptr=0x4027eef8) at gc.c:639
#5  0x08066b25 in mark_entry (key=9762, value=1076358904) at gc.c:405
#6  0x0809de54 in st_foreach (table=0x838b7e8, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#7  0x08066b49 in rb_mark_tbl (tbl=0x838b7e8) at gc.c:414
#8  0x08066f7b in rb_gc_mark (ptr=0x4027ef20) at gc.c:639
#9  0x08066b25 in mark_entry (key=10442, value=1076358944) at gc.c:405
#10 0x0809de54 in st_foreach (table=0x838bbb8, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#11 0x08066b49 in rb_mark_tbl (tbl=0x838bbb8) at gc.c:414
#12 0x08066f7b in rb_gc_mark (ptr=0x4027edb8) at gc.c:639
#13 0x08066b25 in mark_entry (key=10442, value=1076358584) at gc.c:405
#14 0x0809de54 in st_foreach (table=0x838bf88, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#15 0x08066b49 in rb_mark_tbl (tbl=0x838bf88) at gc.c:414
#16 0x08066f7b in rb_gc_mark (ptr=0x4027ec50) at gc.c:639
#17 0x08066b25 in mark_entry (key=10442, value=1076358224) at gc.c:405
#18 0x0809de54 in st_foreach (table=0x838c358, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#19 0x08066b49 in rb_mark_tbl (tbl=0x838c358) at gc.c:414
#20 0x08066f7b in rb_gc_mark (ptr=0x4027eae8) at gc.c:639
#21 0x08066b25 in mark_entry (key=10442, value=1076357864) at gc.c:405
#22 0x0809de54 in st_foreach (table=0x838c728, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#23 0x08066b49 in rb_mark_tbl (tbl=0x838c728) at gc.c:414
#24 0x08066f7b in rb_gc_mark (ptr=0x4027e980) at gc.c:639
#25 0x08066b25 in mark_entry (key=10442, value=1076357504) at gc.c:405
#26 0x0809de54 in st_foreach (table=0x838caf8, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#27 0x08066b49 in rb_mark_tbl (tbl=0x838caf8) at gc.c:414
#28 0x08066f7b in rb_gc_mark (ptr=0x4027e818) at gc.c:639
#29 0x08066b25 in mark_entry (key=10442, value=1076357144) at gc.c:405
#30 0x0809de54 in st_foreach (table=0x838cec8, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#31 0x08066b49 in rb_mark_tbl (tbl=0x838cec8) at gc.c:414
#32 0x08066f7b in rb_gc_mark (ptr=0x4027e6b0) at gc.c:639
#33 0x08066b25 in mark_entry (key=10442, value=1076356784) at gc.c:405
#34 0x0809de54 in st_foreach (table=0x838d298, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#35 0x08066b49 in rb_mark_tbl (tbl=0x838d298) at gc.c:414
#36 0x08066f7b in rb_gc_mark (ptr=0x4027e548) at gc.c:639
#37 0x08066b25 in mark_entry (key=10442, value=1076356424) at gc.c:405
#38 0x0809de54 in st_foreach (table=0x838d668, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
#39 0x08066b49 in rb_mark_tbl (tbl=0x838d668) at gc.c:414
#40 0x08066f7b in rb_gc_mark (ptr=0x4027e3e0) at gc.c:639
#41 0x08066b25 in mark_entry (key=10442, value=1076356064) at gc.c:405
#42 0x0809de54 in st_foreach (table=0x838da38, func=0x8066b14 <mark_entry>, arg=0x0)
    at st.c:489
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) 

 the stack frame is bigger


 rb_id2name(10442) is @prec


Guy Decoux