Debugging a corrupted pmc_alloc_list

Arne Skjærholt arnsholt at gmail.com
Mon Apr 1 15:06:01 UTC 2013


While debugging an issue[0] in Zavolaj (Rakudo's FFI library), I get a
segfault during garbage collection.

The immediate cause of the problem is attempting to write to a garbage
pointer in Parrot_pa_remove (pointer_array.h:141), called from
gc_gms_mark_pmc_header (gc_gms.c:1172). Inspecting  with gdb, the
pmc_alloc_list's ptr field, which is passed to pa_remove, clearly has
a garbage value (along with data and _metadata in the PMC):

(gdb) p *item
$7 = {ptr = 0x21, pmc = {flags = 7809632274704576302, vtable =
0x732e736b6361626c, data = 0x6f, _metadata = 0x21}}

The code that triggers the fault handles callbacks (Perl 6 subs called
from C, via dyncallback), and initially I thought the caching I do
caused the fault. However commenting out the caching does absolutely
nothing, so that's not it apparently.

Does anyone have any tips on how to best track down what's going on?
Could it be as simple as some of my code hanging on to a pointer to a
PMC that has already been GCed for example?

Arne
:wq

0: https://github.com/jnthn/zavolaj/issues/23 is the bug report,
however the offending code lives in the NQP repository


More information about the parrot-dev mailing list