A plea from Rakudo-land

Andrew Whitworth wknight8111 at gmail.com
Sat Jul 4 14:48:20 UTC 2009


On Sat, Jul 4, 2009 at 6:57 AM, Vasily Chekalkin<bacek at bacek.com> wrote:
> Patrick R. Michaud wrote:
> O HAI. I spent few hours in investigations. Now I almost sure that problem
> is in marking objects on C stack. Unfortunately my GC-fu is low and I can't
> fix it. But fwiw steps to catch error.
>
> ...
>
> As we can see C<method_pmc> was collected prematurely. Patch from step 1
> asserts that C<method_pmc> was correct _before_ calling VTABLE_invoke.

Thanks for this, it's very helpful in tracking down this error. When I
run GDB as you suggest, I get this interesting error message:

GC: error obj 0x7f65bd090a60 () has properties

That error message only appears if the PMC contains metadata but is
not flagged with PObj_is_special_PMC_FLAG. That result of that
situation is that the metadata of the PMC (properties, etc) will not
be marked and will be prematurely swept. If I force a break at that
point, here is the backtrace:

#0  0x00007f99d5ccdfdb in Parrot_gc_mark_PObj_alive (interp=0xc2b080,
obj=0x7f99d40a7a60) at src/gc/api.c:242
#1  0x00007f99d5e8adc9 in Parrot_Object_mark (interp=0xc2b080,
pmc=0x191c190) at ./src/pmc/object.pmc:197
#2  0x00007f99d5cd0797 in mark_special (interp=0xc2b080,
obj=0x191c190) at src/gc/mark_sweep.c:460
#3  0x00007f99d5ccdf63 in Parrot_gc_mark_PObj_alive (interp=0xc2b080,
obj=0x191c190) at src/gc/api.c:229
#4  0x00007f99d5cd1eb5 in trace_mem_block (interp=0xc2b080,
lo_var_ptr=140736921765432, hi_var_ptr=140736921762912) at
src/gc/system.c:456
#5  0x00007f99d5cd1f63 in trace_system_stack (interp=0xc2b080) at
src/gc/system.c:242
#6  0x00007f99d5cd1fda in trace_system_areas (interp=0xc2b080) at
src/gc/system.c:216
#7  0x00007f99d5cd1884 in Parrot_gc_trace_root (interp=0xc2b080,
trace=GC_TRACE_FULL) at src/gc/mark_sweep.c:231
#8  0x00007f99d5ccfae2 in gc_ms_trace_active_PMCs (interp=0xc2b080,
trace=GC_TRACE_FULL) at src/gc/gc_ms.c:286
#9  0x00007f99d5ccfd40 in gc_ms_mark_and_sweep (interp=0xc2b080,
flags=1) at src/gc/gc_ms.c:207
#10 0x00007f99d5cccffd in Parrot_gc_mark_and_sweep (interp=0xc2b080,
flags=1) at src/gc/api.c:856
#11 0x00007f99d5ccf982 in gc_ms_more_traceable_objects
(interp=0xc2b080, pool=0xc2c770) at src/gc/gc_ms.c:374
#12 0x00007f99d5ccf39b in gc_ms_get_free_object (interp=0xc2b080,
pool=0xc2c770) at src/gc/gc_ms.c:434
#13 0x00007f99d5ccda41 in Parrot_gc_new_pmc_header (interp=0xc2b080,
flags=1024) at src/gc/api.c:335
#14 0x00007f99d5d37023 in get_new_pmc_header (interp=0xc2b080,
base_type=48, flags=1024) at src/pmc.c:399
#15 0x00007f99d5d375de in pmc_new (interp=0xc2b080, base_type=48) at
src/pmc.c:119
#16 0x00007f99d5e69516 in Parrot_FixedPMCArray_clone (interp=0xc2b080,
pmc=0x191c2e0) at ./src/pmc/fixedpmcarray.pmc:103
#17 0x00007f99d5e9ef62 in Parrot_ResizablePMCArray_clone
(interp=0xc2b080, pmc=0x191c2e0) at
./src/pmc/resizablepmcarray.pmc:594
#18 0x00007f99d5d27231 in Parrot_oo_clone_object (interp=0xc2b080,
pmc=0x19216b0, class_=0x1923870, dest=0x0) at src/oo.c:306
#19 0x00007f99d5e8b0ca in Parrot_Object_clone (interp=0xc2b080,
pmc=0x19216b0) at ./src/pmc/object.pmc:666
#20 0x00007f99d5c6ee84 in Parrot_copy_p_p (cur_opcode=0x7f99d30cc218,
interp=0xc2b080) at src/ops/set.ops:500
#21 0x00007f99d5d39d0b in runops_fast_core (interp=0xc2b080,
pc=0x7f99d30cc218) at src/runcore/cores.c:288
#22 0x00007f99d5d393dc in runops_int (interp=0xc2b080, offset=146524)
at src/runcore/main.c:987
#23 0x00007f99d5cdfdaa in runops (interp=0xc2b080, offs=146524) at
src/call/ops.c:107
#24 0x00007f99d5ce01b9 in runops_args (interp=0xc2b080, sub=0x10a14b0,
obj=0xcae810, meth_unused=0x0, sig=0x7f99d5f010b7 "P",
ap=0x7fffde3a8330)
    at src/call/ops.c:256
#25 0x00007f99d5ce158c in Parrot_runops_fromc_args (interp=0xc2b080,
sub=0x10a14b0, sig=0x7f99d5f010b7 "P") at src/call/ops.c:325
#26 0x00007f99d5d2f4f3 in run_sub (interp=0xc2b080, sub_pmc=0x10a14b0)
at src/packfile.c:686
#27 0x00007f99d5d2f844 in do_1_sub_pragma (interp=0xc2b080,
sub_pmc=0x10a14b0, action=PBC_MAIN) at src/packfile.c:778
#28 0x00007f99d5d2fa78 in do_sub_pragmas (interp=0xc2b080,
self=0xd30110, action=PBC_MAIN, eval_pmc=0x0) at src/packfile.c:932
#29 0x00007f99d5d2fb65 in PackFile_fixup_subs (interp=0xc2b080,
what=PBC_MAIN, eval=0x0) at src/packfile.c:4903
#30 0x00007f99d5ed032d in imcc_run_pbc (interp=0xc2b080, obj_file=0,
output_file=0x0, argc=2, argv=0x7fffde3a8798) at
compilers/imcc/main.c:799
#31 0x00007f99d5ed0fa1 in imcc_run (interp=0xc2b080,
sourcefile=0x7fffde3aa6b4 "./perl6.pbc", argc=2, argv=0x7fffde3a8798)
at compilers/imcc/main.c:1092
#32 0x0000000000400bc4 in main (argc=2, argv=0x7fffde3a8798) at src/main.c:60

This is quite interesting because it suggests that somewhere in the
Object cloning logic a PMC is not being properly anchored early enough
before a GC run is kicked off. It's also interesting that the stack
marking code is indeed included here.

I'll post more as I find it.

--Andrew Whitworth


More information about the parrot-dev mailing list