On Thu, 08 Jun 2000 07:11:47 +0200, Richard Foley wrote:
>The short script below reproduces a core-dump related to
>Perl 5.6.0 and caller() / @DB::args.
>It is small and self-contained. I have included a bare 14 line version,
>followed by a more verbose one.
This happens due to an "optimization" in non-USE_ITHREADS builds that
assumed @_ needn't be cleared at the end of a subroutine call if it's
contents weren't reference counted. @DB::args breaks that assumption.
Thanks for the test case.
Sarathy
[EMAIL PROTECTED]
-----------------------------------8<-----------------------------------
Change 6214 by gsar@auger on 2000/06/08 13:57:54
@_ can't have junk in it even in the non-USE_ITHREADS case because
caller() wants to populate @DB::args with it (causes a coredump
in Carp::confess())
Affected files ...
... //depot/perl/cop.h#49 edit
... //depot/perl/t/op/runlevel.t#16 edit
Differences ...
==== //depot/perl/cop.h#49 (text) ====
Index: perl/cop.h
--- perl/cop.h.~1~ Thu Jun 8 06:58:03 2000
+++ perl/cop.h Thu Jun 8 06:58:03 2000
@@ -106,13 +106,9 @@
} STMT_END
#endif /* USE_THREADS */
-#ifdef USE_ITHREADS
- /* junk in @_ spells trouble when cloning CVs, so don't leave any */
-# define CLEAR_ARGARRAY() av_clear(cx->blk_sub.argarray)
-#else
-# define CLEAR_ARGARRAY() NOOP
-#endif /* USE_ITHREADS */
-
+/* junk in @_ spells trouble when cloning CVs and in pp_caller(), so don't
+ * leave any */
+#define CLEAR_ARGARRAY() av_clear(cx->blk_sub.argarray)
#define POPSUB(cx,sv) \
STMT_START { \
==== //depot/perl/t/op/runlevel.t#16 (xtext) ====
Index: perl/t/op/runlevel.t
--- perl/t/op/runlevel.t.~1~ Thu Jun 8 06:58:03 2000
+++ perl/t/op/runlevel.t Thu Jun 8 06:58:03 2000
@@ -349,3 +349,18 @@
bar
B 2
bar
+########
+sub n { 0 }
+sub f { my $x = shift; d(); }
+f(n());
+f();
+
+sub d {
+ my $i = 0; my @a;
+ while (do { { package DB; @a = caller($i++) } } ) {
+ @a = @DB::args;
+ for (@a) { print "$_\n"; $_ = '' }
+ }
+}
+EXPECT
+0
End of Patch.