avoid premature free of referent in list assign

Programming / Compilers / PERL - David Mitchell [iabyn.com] - 24 November 2016 07:37 UTC

RT #130132

My recent commit v5.25.6-266-ga083329 made it so that perl could sometimes avoid mortalising the referent when assigning to a reference (e.g. for $ref1 = $ref2, where $$ref1 has a ref count of 1).

Unfortunately it turns out that list assign relied on this behaviour to avoid premature freeing, e.g.

($ref1, $x) = ($y, $$ref1);

where $$ref1 needs to continue to live for at least the rest of the assign.

This commit fixes it by mortalising the referent in pp_assign when required.

d24e3eb avoid premature free of referent in list assign
op.c | 16 ++++++++++++++++
pp_hot.c | 20 ++++++++++++++++++++
t/op/aassign.t | 34 ++++++++++++++++++++++++++++++++++
t/perf/benchmarks | 13 +++++++++++++
4 files changed, 83 insertions(+)

Upstream: perl5.git.perl.org


  • Share