Skip to content

Commit

Permalink
Block the GC while executing a proxied method
Browse files Browse the repository at this point in the history
Proxy runs methods on the target with the target's interp. If GC is
triggered during this run, the foreign interp's GC could find our PMCs
on the call stack. It would also not find any PMCs which are on the
foreign interp's callstack. And most of all it could be that the foreign
interp also starts collecting garbage at the same time...

So we block the foreign GC to prevent this from happening.
  • Loading branch information
niner committed Mar 11, 2012
1 parent 5165f6a commit 97254da
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Parrot/Pmc2c/PMC/Proxy.pm
Expand Up @@ -89,7 +89,14 @@ sub _generate_proxy_method {

my $body = $method->return_type eq 'PMC*'
? <<BODY
PMC * result = $call;
PMC * result;
/* otherwise the GC could find foreign PMCs on the stack */
Parrot_block_GC_mark(proxied_interp);
result = $call;
Parrot_unblock_GC_mark(proxied_interp);
return (PMC_IS_NULL(result)
? PMCNULL
Expand Down

0 comments on commit 97254da

Please sign in to comment.