It's possible for an interpreter to get cloned with an SV copied that ends
up only linked from @_. For example, local $x causes a link to the
original $x SV to be added to the save stack, but when cloning a thread
the save stack isn't copied. If the old $x was also in someone's @_,
then it gets copied, but because @_'s elements aren't normally reference
counted, old $x ends up with a refcount of zero, and you get a "leaked"
warning when the thread exits.
The workaround is to reify any reify-able AVs in the cloned interpreter
during cloning.
Also fixes [perl #70602], [perl #70974]
else {
while (items-- > 0)
*dst_ary++ = sv_dup(*src_ary++, param);
+ if (!(param->flags & CLONEf_COPY_STACKS)
+ && AvREIFY(sstr))
+ {
+ av_reify(MUTABLE_AV(dstr)); /* #41138 */
+ }
}
items = AvMAX((const AV *)sstr) - AvFILLp((const AV *)sstr);
while (items-- > 0) {
EOI
}
+} # TODO
+
# Scalars leaked: 1
fresh_perl_is(<<'EOI', 'ok', { }, 'Bug #41138');
use threads;
print 'ok';
EOI
-} # TODO
# [perl #45053] Memory corruption with heavy module loading in threads
#