Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Perl_rpp_is_lone() for immortals.
Perl_rpp_is_lone() checks whether an SV is kept alive only by the args and/or temps stack, and thus can in various circumstances be used directly rather than copying - such as a return value from a function, or assigning a value to an array or hash. However, this assumption fails on immortal SVs like PL_sv_undef. Their refcount can reach 1 but they should still be copied rather than stolen. This showed itself as an extremely intermittent failure in cpan/Test-Harness/t/compat/test-harness-compat.t It only showed up when both these conditions were met: - on DEBUGGING builds, because that sets the initial ref count of the immortals to 1000 rather than I32_MAX, making such problems easier to reproduce; *and* - under PERL_RC_STACK, because only on that build do you have SVs on the args stack (but not temps stack) with RC==1 which are stealable. Also under the RC build, as an optimisation, &PL_sv_undef is often pushed on the stack without incrementing its RC. Thus it is more liklely to reach RC==1. I don't know why the failure on that test was intermittent, even after setting PERL_HASH_SEED=0. Perhaps it was timing related. Certainly anything which made it slower, such as strace, valgrind or ASAN, made the problem go away or fail only after days rather than minutes. This commit also decreases the value of SvREFCNT_IMMORTAL on debugging builds from 1000 to 10 under PERL_RC_STACK, to make such issues/bugs more likely to be triggered.
- Loading branch information