This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
handle freed backref array in global cleanup
authorDavid Mitchell <davem@iabyn.com>
Wed, 13 Apr 2011 13:35:09 +0000 (14:35 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Apr 2011 13:49:09 +0000 (14:49 +0100)
commitda0c0b273c42c8a3f17664cdbe99318311f652af
tree40f4900feb7b7dbdccc797da339825eb9970aeae
parent673d8593b7ef274dadbfff97fd641e3c563fc716
handle freed backref array in global cleanup

[perl #88330]

If a thinggy is heavily leaked, so that it takes multiple passes through
Perl_sv_clean_all to get its refcount to zero, then if it has weak refs to
it, its backref array may get freed before it.  We already set the
refcount of the array to 2 to preserve it across one pass of
Perl_sv_clean_all, but I can't think of a way of protecting it more
generally (short of using a private array structure rather than an AV).

In the past, this caused a scary assertion failure.

Now instead, just skip if we're in global cleanup and the array is freed.
This isn't ideal, but its reasonably robust, as we don't reuse freed SVs
once in global cleanup (so the freed AV hangs around to be identified as
such).
sv.c
t/op/ref.t