From: Gurusamy Sarathy <gsar@cpan.org>
Date: Wed, 29 Oct 1997 19:36:25 +0000 (-0500)
Subject: [win32] don't share TARG unless -DUSE_BROKEN_PAD_RESET
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9bb4600de3a7f46a4972e4a2d2e5d1ea333bb0a;p=p5sagit%2Fp5-mst-13.2.git

[win32] don't share TARG unless -DUSE_BROKEN_PAD_RESET
	Message-Id: <199710300036.TAA01004@aatma.engin.umich.edu>
	Subject: [PATCH] Don't use broken pad_reset() (was Re: Perl bug in 5.004_03 )

p4raw-id: //depot/win32/perl@491
---

diff --git a/op.c b/op.c
index c5c475a..593667d 100644
--- a/op.c
+++ b/op.c
@@ -393,7 +393,8 @@ pad_alloc(I32 optype, U32 tmptype)
 			  (unsigned long) thr, (unsigned long) curpad,
 			  (long) retval, op_name[optype]));
 #else
-    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad alloc %ld for %s\n",
+    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad 0x%lx alloc %ld for %s\n",
+			  (unsigned long) curpad,
 			  (long) retval, op_name[optype]));
 #endif /* USE_THREADS */
     return (PADOFFSET)retval;
@@ -414,7 +415,8 @@ pad_sv(PADOFFSET po)
 #else
     if (!po)
 	croak("panic: pad_sv po");
-    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad sv %d\n", po));
+    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad 0x%lx sv %d\n",
+			  (unsigned long) curpad, po));
 #endif /* USE_THREADS */
     return curpad[po];		/* eventually we'll turn this into a macro */
 }
@@ -438,7 +440,8 @@ pad_free(PADOFFSET po)
     DEBUG_X(PerlIO_printf(Perl_debug_log, "0x%lx Pad 0x%lx free %d\n",
 			  (unsigned long) thr, (unsigned long) curpad, po));
 #else
-    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad free %d\n", po));
+    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad 0x%lx free %d\n",
+			  (unsigned long) curpad, po));
 #endif /* USE_THREADS */
     if (curpad[po] && curpad[po] != &sv_undef)
 	SvPADTMP_off(curpad[po]);
@@ -463,7 +466,8 @@ pad_swipe(PADOFFSET po)
     DEBUG_X(PerlIO_printf(Perl_debug_log, "0x%lx Pad 0x%lx swipe %d\n",
 			  (unsigned long) thr, (unsigned long) curpad, po));
 #else
-    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad swipe %d\n", po));
+    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad 0x%lx swipe %d\n",
+			  (unsigned long) curpad, po));
 #endif /* USE_THREADS */
     SvPADTMP_off(curpad[po]);
     curpad[po] = NEWSV(1107,0);
@@ -472,9 +476,16 @@ pad_swipe(PADOFFSET po)
 	padix = po - 1;
 }
 
+/* XXX pad_reset() is currently disabled because it results in serious bugs.
+ * It causes pad temp TARGs to be shared between OPs. Since TARGs are pushed
+ * on the stack by OPs that use them, there are several ways to get an alias
+ * to  a shared TARG.  Such an alias will change randomly and unpredictably.
+ * We avoid doing this until we can think of a Better Way.
+ * GSAR 97-10-29 */
 void
 pad_reset(void)
 {
+#ifdef USE_BROKEN_PAD_RESET
     dTHR;
     register I32 po;
 
@@ -484,7 +495,8 @@ pad_reset(void)
     DEBUG_X(PerlIO_printf(Perl_debug_log, "0x%lx Pad 0x%lx reset\n",
 			  (unsigned long) thr, (unsigned long) curpad));
 #else
-    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad reset\n"));
+    DEBUG_X(PerlIO_printf(Perl_debug_log, "Pad 0x%lx reset\n",
+			  (unsigned long) curpad));
 #endif /* USE_THREADS */
     if (!tainting) {	/* Can't mix tainted and non-tainted temporaries. */
 	for (po = AvMAX(comppad); po > padix_floor; po--) {
@@ -493,6 +505,7 @@ pad_reset(void)
 	}
 	padix = padix_floor;
     }
+#endif
     pad_reset_pending = FALSE;
 }