This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid premature free of referent in list assign
authorDavid Mitchell <davem@iabyn.com>
Tue, 22 Nov 2016 16:41:54 +0000 (16:41 +0000)
committerDavid Mitchell <davem@iabyn.com>
Thu, 24 Nov 2016 13:37:07 +0000 (13:37 +0000)
commitd24e3eb1402c1294265f99342e2ec0ecfd0f5d34
tree18bf0b9747d658b792417fbd6e2c672ac4c9bea1
parentfb882494267edb919d5a9a3fe0aca2dfeb30d012
avoid premature free of referent in list assign

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.
op.c
pp_hot.c
t/op/aassign.t
t/perf/benchmarks