petdance/scratch — Issue #450: clone_p_p segfaults with self-referential Hash pmc.
Author: petdance
Created: 2011-11-01 05:34:49+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

If a complex data structure, built with Hash and Array structures, is self-referencing, running clone_p_p on it will quickly segfault.

{{{
our %Global_hash;

sub bsu() {
say("BSU: starting.");
%Global_hash := 1;
%Global_hash := %Global_hash;

my %local := %Global_hash;

my $result := Q:PIR {{
$P0 = find_lex '%local'
%r = clone $P0
}};

say("BSU: returning.");
return $result;

}

bsu();
}}}

The solution here is likely to be involved -- perhaps disabling the GC and using the mark bit to track what has been cloned. But segmentation fault is not a parrot exception, which is what a memory problem should become.

Dukeleto confirms this problem exists on Darwin, and his Linux box.

FYI: I discovered this because PCT clones the symbol table of PAST::Block nodes.
Trac ID #1015