From: Gurusamy Sarathy Date: Fri, 20 Sep 1996 19:38:57 +0000 (-0400) Subject: Re: "Attempt to free non-existent shared string"? (with patch) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf5b86ae2f8af4d8daece5777d77a067ab9cf194;p=p5sagit%2Fp5-mst-13.2.git Re: "Attempt to free non-existent shared string"? (with patch) I found a subtle problem with the lazydelete mechanism (which is used to postpone the delete of a entry that may be getting iterated over). I was using the HeKLEN slot to hold the hint, but the real HeKLEN is needed later to call unsharepvn(). This means that only magical hash entries can use the HeKLEN slot to hold flags. Here's a tested patch against 5.00305 that fixes the problem. The patch simply moves the LAZYDEL hint to become a SV-level private flag. --- diff --git a/hv.h b/hv.h index a9de8ca..5c41309 100644 --- a/hv.h +++ b/hv.h @@ -43,10 +43,8 @@ struct xpvhv { } STMT_END -/* these hash entry flags ride on hent_klen */ - -#define HEf_LAZYDEL -1 /* entry must be deleted during next iter step */ -#define HEf_SVKEY -2 /* hent_key is a SV* (only for magic/tied HVs) */ +/* these hash entry flags ride on hent_klen (for use only in magic/tied HVs) */ +#define HEf_SVKEY -2 /* hent_key is a SV* */ #define Nullhv Null(HV*) @@ -63,6 +61,10 @@ struct xpvhv { #define HvSHAREKEYS_on(hv) (SvFLAGS(hv) |= SVphv_SHAREKEYS) #define HvSHAREKEYS_off(hv) (SvFLAGS(hv) &= ~SVphv_SHAREKEYS) +#define HvLAZYDEL(hv) (SvFLAGS(hv) & SVphv_LAZYDEL) +#define HvLAZYDEL_on(hv) (SvFLAGS(hv) |= SVphv_LAZYDEL) +#define HvLAZYDEL_off(hv) (SvFLAGS(hv) &= ~SVphv_LAZYDEL) + #ifdef OVERLOAD /* Maybe amagical: */