develooper Front page | perl.perl5.porters | Postings from April 2003

Re: [perl #21914] 3-arg open + local $fh + strict coredump

Thread Previous
From:
Enache Adrian
Date:
April 9, 2003 17:45
Subject:
Re: [perl #21914] 3-arg open + local $fh + strict coredump
Message ID:
20030410014610.GA21521@ratsnest.hole
On Wed, Apr 09, 2003 at 06:03:48PM -0000, Jarkko Hietaniemi wrote:
> At some point after 5.8.0 the following code
> 
> use strict;
> open(local $f, '<', '/might/exist/might/not');
> my @rows = <$f>;
> 
> changed behaviour from
> 
> Global symbol "$f" requires explicit package name at o.t line 2.
> Global symbol "$f" requires explicit package name at o.t line 3.
> Execution of o.t aborted due to compilation errors.
> 
> to
> 
> zsh: 386540 segmentation fault (core dumped)  ./perl -Ilib o.t

a simpler example:
$ perl -e 'BEGIN { $^H |= 0x400 } @b = <$f>'
Segmentation fault

The SEGV happens in Perl_newASSIGNOP op.c:3089 because SvCUR() tries
to dereference a NULL 'gv' pointer.
That 'gv' is NULL because change #17942 removed PL_nullstash,
from which the return value of gv_fetchpv had to be fetched when
HINT_STRICT_VARS was set.
	see gv.c:722,734,759 and the gv.c hunk in change #17942
	(it should be now line 764)

I don't think that gv_fetchpv returning NULL when its 'add' argument 
is non-zero is exactly right - and I failed to see what was so
wrong with PL_nullstash.

Below I simply test for a non-null 'gv' - but, again, what
harm was PL_nullstash doing ?

Regards
Adi

------------------------------------------------------------------------
--- /arc/bleadperl/op.c	2003-04-08 23:56:49.000000000 +0300
+++ bleadperl/op.c	2003-04-10 04:00:38.000000000 +0300
@@ -3086,7 +3086,8 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *le
 		if (PL_opargs[curop->op_type] & OA_DANGEROUS) {
 		    if (curop->op_type == OP_GV) {
 			GV *gv = cGVOPx_gv(curop);
-			if (gv == PL_defgv || (int)SvCUR(gv) == PL_generation)
+			if (!gv || gv == PL_defgv ||
+				(int)SvCUR(gv) == PL_generation)
 			    break;
 			SvCUR(gv) = PL_generation;
 		    }
--- /arc/bleadperl/t/lib/strict/vars	2002-01-10 17:53:14.000000000 +0200
+++ bleadperl/t/lib/strict/vars	2003-04-10 04:28:40.000000000 +0300
@@ -421,3 +421,12 @@
 EXPECT
 Global symbol "@i_like_crackers" requires explicit package name at - line 7.
 Execution of - aborted due to compilation errors.
+########
+
+# [perl #21914] New bug > 5.8.0. Uses to dump core.
+use strict 'vars';
+@k = <$k>;
+EXPECT
+Global symbol "@k" requires explicit package name at - line 4.
+Global symbol "$k" requires explicit package name at - line 4.
+Execution of - aborted due to compilation errors.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About