This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tweak the GV downgrading of f7461760 to avoid free or nearly freed GVs.
authorNicholas Clark <nick@ccl4.org>
Sun, 8 Nov 2009 22:04:10 +0000 (22:04 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 8 Nov 2009 22:04:10 +0000 (22:04 +0000)
commitb327b36f413e77afd7eed00e6517a0e8cb961c48
treec805356ec3f6c3d1976eeab360b4bb64afb0991c
parent70938cb944714e91b284c1fcdab01a6ab2f49034
Tweak the GV downgrading of f7461760 to avoid free or nearly freed GVs.

It's possible during global destruction that the GV is freed before the
optree. Whilst the SvREFCNT_inc is happy to bump from 0 to 1 on a freed SV,
the corresponding SvREFCNT_dec from 1 to 0 will trigger an assertion
failure, because the entry to sv_clear checks that the scalar is not already
freed.  A check of for !SvIS_FREED(gv) turns out to be invalid, because
during global destruction the reference count can be forced down to zero
(with SVf_BREAK set).  In which case raising to 1 and then dropping to 0
triggers cleanup before it should happen.  I *think* that this might
actually be a general, systematic, weakness of the whole idea of SVf_BREAK,
in that code *is* allowed to raise and lower references during global
destruction, so any *valid* code that happens to do this during global
destruction might well trigger premature cleanup.
op.c