Change 21470 by [EMAIL PROTECTED] on 2003/10/16 20:03:44
Ensure PL_comppad/curpad point to PL_main_cv's padlist when
PL_main_root is freed; this may not have been be the case if a
thread other than the main one is the last to be destroyed
Affected files ...
... //depot/perl/ext/threads/t/thread.t#10 edit
... //depot/perl/pad.h#9 edit
... //depot/perl/perl.c#526 edit
Differences ...
==== //depot/perl/ext/threads/t/thread.t#10 (text) ====
Index: perl/ext/threads/t/thread.t
--- perl/ext/threads/t/thread.t#9~19707~ Sat Jun 7 06:27:01 2003
+++ perl/ext/threads/t/thread.t Thu Oct 16 13:03:44 2003
@@ -12,7 +12,7 @@
use ExtUtils::testlib;
use strict;
-BEGIN { $| = 1; print "1..25\n" };
+BEGIN { $| = 1; print "1..26\n" };
use threads;
use threads::shared;
@@ -153,5 +153,10 @@
ok((keys %rand == 25), "Check that rand works after a new thread");
}
+# bugid #24165
+
+run_perl(prog =>
+ 'use threads; sub a{threads->new(shift)} $t = a sub{}; $t->tid; $t->join;
$t->tid');
+is($?, 0, 'coredump in global destruction');
==== //depot/perl/pad.h#9 (text) ====
Index: perl/pad.h
--- perl/pad.h#8~19242~ Wed Apr 16 13:14:01 2003
+++ perl/pad.h Thu Oct 16 13:03:44 2003
@@ -105,6 +105,9 @@
Set the current pad to be pad C<n> in the padlist, saving
the previous current pad.
+=for apidoc m|void|PAD_SET_CUR_NOSAVE |PADLIST padlist|I32 n
+like PAD_SET_CUR, but without the save
+
=for apidoc m|void|PAD_SAVE_SETNULLPAD
Save the current pad then set it to null.
@@ -133,13 +136,17 @@
? AvARRAY((AV*)(AvARRAY(padlist)[1]))[po] : Nullsv;
-#define PAD_SET_CUR(padlist,n) \
- SAVECOMPPAD(); \
+#define PAD_SET_CUR_NOSAVE(padlist,n) \
PL_comppad = (PAD*) (AvARRAY(padlist)[n]); \
PL_curpad = AvARRAY(PL_comppad); \
DEBUG_Xv(PerlIO_printf(Perl_debug_log, \
"Pad 0x%"UVxf"[0x%"UVxf"] set_cur depth=%d\n", \
PTR2UV(PL_comppad), PTR2UV(PL_curpad), (int)(n)));
+
+
+#define PAD_SET_CUR(padlist,n) \
+ SAVECOMPPAD(); \
+ PAD_SET_CUR_NOSAVE(padlist,n);
#define PAD_SAVE_SETNULLPAD() SAVECOMPPAD(); \
==== //depot/perl/perl.c#526 (text) ====
Index: perl/perl.c
--- perl/perl.c#525~21466~ Thu Oct 16 01:52:50 2003
+++ perl/perl.c Thu Oct 16 13:03:44 2003
@@ -354,6 +354,10 @@
/* Destroy the main CV and syntax tree */
if (PL_main_root) {
+ /* ensure comppad/curpad to refer to main's pad */
+ if (CvPADLIST(PL_main_cv)) {
+ PAD_SET_CUR_NOSAVE(CvPADLIST(PL_main_cv), 1);
+ }
op_free(PL_main_root);
PL_main_root = Nullop;
}
End of Patch.