Change 13473 by gsar@onru on 2001/12/05 15:08:18
revert change#10451,10471; it was a naive fix that simply
reintroduced the memory leak!
Affected files ...
.... //depot/maint-5.6/perl/op.c#51 edit
.... //depot/maint-5.6/perl/t/op/misc.t#19 edit
Differences ...
==== //depot/maint-5.6/perl/op.c#51 (text) ====
Index: perl/op.c
--- perl/op.c.~1~ Wed Dec 5 08:15:05 2001
+++ perl/op.c Wed Dec 5 08:15:05 2001
@@ -4117,15 +4117,9 @@
* CV, they don't hold a refcount on the outside CV. This avoids
* the refcount loop between the outer CV (which keeps a refcount to
* the closure prototype in the pad entry for pp_anoncode()) and the
- * closure prototype, and the ensuing memory leak. This does not
- * apply to closures generated within eval"", since eval"" CVs are
- * ephemeral. --GSAR */
- if (!CvANON(cv) || CvCLONED(cv)
- || (CvOUTSIDE(cv) && SvTYPE(CvOUTSIDE(cv)) == SVt_PVCV
- && CvEVAL(CvOUTSIDE(cv)) && !CvGV(CvOUTSIDE(cv))))
- {
+ * closure prototype, and the ensuing memory leak. --GSAR */
+ if (!CvANON(cv) || CvCLONED(cv))
SvREFCNT_dec(CvOUTSIDE(cv));
- }
CvOUTSIDE(cv) = Nullcv;
if (CvPADLIST(cv)) {
/* may be during global destruction */
@@ -4682,17 +4676,12 @@
}
}
- /* If a potential closure prototype, don't keep a refcount on
- * outer CV, unless the latter happens to be a passing eval"".
+ /* If a potential closure prototype, don't keep a refcount on outer CV.
* This is okay as the lifetime of the prototype is tied to the
* lifetime of the outer CV. Avoids memory leak due to reference
* loop. --GSAR */
- if (!name && CvOUTSIDE(cv)
- && !(SvTYPE(CvOUTSIDE(cv)) == SVt_PVCV
- && CvEVAL(CvOUTSIDE(cv)) && !CvGV(CvOUTSIDE(cv))))
- {
+ if (!name)
SvREFCNT_dec(CvOUTSIDE(cv));
- }
if (name || aname) {
char *s;
==== //depot/maint-5.6/perl/t/op/misc.t#19 (xtext) ====
Index: perl/t/op/misc.t
--- perl/t/op/misc.t.~1~ Wed Dec 5 08:15:05 2001
+++ perl/t/op/misc.t Wed Dec 5 08:15:05 2001
@@ -593,16 +593,6 @@
EXPECT
ok
########
-# test that closures generated by eval"" hold on to the CV of the eval""
-# for their entire lifetime
-$code = eval q[
- sub { eval '$x = "ok 1\n"'; }
-];
-&{$code}();
-print $x;
-EXPECT
-ok 1
-########
# This test is here instead of pragma/locale.t because
# the bug depends on in the internal state of the locale
# settings and pragma/locale messes up that state pretty badly.
End of Patch.