petdance/scratch — Issue #112: clone_p_p segfaults with self-referential Hash pmc.
Author: petdance
Created: 2011-11-14 06:06:52+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.

Originally http://trac.parrot.org/parrot/ticket/1015