From: Dave Mitchell Date: Sun, 24 Aug 2008 12:16:28 +0000 (+0000) Subject: Don't add freed SVF_BREAK scalars to the freed list. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=990198f0755a90e7230c3598d2d36d7d5ef7d95e;p=p5sagit%2Fp5-mst-13.2.git Don't add freed SVF_BREAK scalars to the freed list. This may still be referenced, so don't reuse. p4raw-id: //depot/perl@34220 --- diff --git a/sv.c b/sv.c index f56d70c..6089a00 100644 --- a/sv.c +++ b/sv.c @@ -192,13 +192,23 @@ Perl_offer_nice_chunk(pTHX_ void *const chunk, const U32 chunk_size) # define POSION_SV_HEAD(sv) #endif +/* Mark an SV head as unused, and add to free list. + * + * If SVf_BREAK is set, skip adding it to the free list, as this SV had + * its refcount artificially decremented during global destruction, so + * there may be dangling pointers to it. The last thing we want in that + * case is for it to be reused. */ + #define plant_SV(p) \ STMT_START { \ + const U32 old_flags = SvFLAGS(p); \ FREE_SV_DEBUG_FILE(p); \ POSION_SV_HEAD(p); \ - SvARENA_CHAIN(p) = (void *)PL_sv_root; \ SvFLAGS(p) = SVTYPEMASK; \ - PL_sv_root = (p); \ + if (!(old_flags & SVf_BREAK)) { \ + SvARENA_CHAIN(p) = (void *)PL_sv_root; \ + PL_sv_root = (p); \ + } \ --PL_sv_count; \ } STMT_END