Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment ignores magick when the RHS holds a glob #10585

Closed
p5pRT opened this issue Aug 29, 2010 · 6 comments
Closed

Assignment ignores magick when the RHS holds a glob #10585

p5pRT opened this issue Aug 29, 2010 · 6 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Aug 29, 2010

Migrated from rt.perl.org#77498 (status was 'resolved')

Searchable as RT77498$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 29, 2010

From @cpansprout

#!perl -l
sub TIESCALAR{bless[]}
sub STORE{}
sub FETCH{1}
tie my $t, "";
$t = *foo;
$x = $t;
print $x; # prints *main​::foo


Flags​:
  category=core
  severity=low


Site configuration information for perl 5.13.4​:

Configured by sprout at Fri Aug 20 23​:24​:53 PDT 2010.

Summary of my perl5 (revision 5 version 13 subversion 4 patch v5.13.4-16-g16c9153) configuration​:
  Snapshot of​: 9b47cdd
  Platform​:
  osname=darwin, osvers=10.4.0, archname=darwin-2level
  uname='darwin pint.local 10.4.0 darwin kernel version 10.4.0​: fri apr 23 18​:28​:53 pdt 2010; root​:xnu-1504.7.4~1release_i386 i386 '
  config_args='-de -Dusedevel'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
  optimize='-O3',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -lc
  libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'

Locally applied patches​:
 


@​INC for perl 5.13.4​:
  /usr/local/lib/perl5/site_perl/5.13.4/darwin-2level
  /usr/local/lib/perl5/site_perl/5.13.4
  /usr/local/lib/perl5/5.13.4/darwin-2level
  /usr/local/lib/perl5/5.13.4
  /usr/local/lib/perl5/site_perl
  .


Environment for perl 5.13.4​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/sprout
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/bin​:/bin​:/usr/sbin​:/sbin​:/usr/local/bin​:/usr/X11/bin​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 29, 2010

From @cpansprout

On Aug 29, 2010, at 1​:48 PM, Father Chrysostomos wrote​:

#!perl -l
sub TIESCALAR{bless[]}
sub STORE{}
sub FETCH{1}
tie my $t, "";
$t = *foo;
$x = $t;
print $x; # prints *main​::foo

This patch won’t apply without the one for bug #77362 applied first.

If the patch for bug #77496 is not applied first, too, this one will cause test failures, as it triggers that bug.

This modifies a test in t/op/tie_fetch_count.t, which currently relies on this bug. *{} is another one of those operators that can return its operand, like || and &&.

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 29, 2010

From @cpansprout

From​: Father Chrysostomos <sprout@​cpan.org>

[perl #77498] Assignment ignores magick when the RHS holds a glob

This also modifies a test in t/op/tie_fetch_count.t, which was rely-
ing on this bug. See bug #76814 for details.

Inline Patch
diff -Nup blead-77362-glob2lv8/sv.c blead-77362-glob2lv9/sv.c
--- blead-77362-glob2lv8/sv.c	2010-08-26 04:31:32.000000000 -0700
+++ blead-77362-glob2lv9/sv.c	2010-08-26 04:54:45.000000000 -0700
@@ -3875,22 +3875,17 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, regi
 	/* case SVt_BIND: */
     case SVt_PVLV:
     case SVt_PVGV:
-	if (isGV_with_GP(sstr) && dtype <= SVt_PVLV) {
-	    glob_assign_glob(dstr, sstr, dtype);
-	    return;
-	}
 	/* SvVALID means that this PVGV is playing at being an FBM.  */
-	/*FALLTHROUGH*/
 
     case SVt_PVMG:
 	if (SvGMAGICAL(sstr) && (flags & SV_GMAGIC)) {
 	    mg_get(sstr);
 	    if (SvTYPE(sstr) != stype)
 		stype = SvTYPE(sstr);
-	    if (isGV_with_GP(sstr) && dtype <= SVt_PVLV) {
+	}
+	if (isGV_with_GP(sstr) && dtype <= SVt_PVLV) {
 		    glob_assign_glob(dstr, sstr, dtype);
 		    return;
-	    }
 	}
 	if (stype == SVt_PVLV)
 	    SvUPGRADE(dstr, SVt_PVNV);
diff -Nurp blead-77362-glob2lv8/t/op/gmagic.t blead-77362-glob2lv9/t/op/gmagic.t
--- blead-77362-glob2lv8/t/op/gmagic.t	2009-11-19 08:51:40.000000000 -0800
+++ blead-77362-glob2lv9/t/op/gmagic.t	2010-08-26 04:44:07.000000000 -0700
@@ -6,7 +6,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-print "1..20\n";
+print "1..22\n";
 
 my $t = 1;
 tie my $c => 'Tie::Monitor';
@@ -54,6 +54,13 @@ ok_string($s, '00', 3, 1);
 $s = chop($c);
 ok_string($s, '0', 1, 1);
 
+# Assignment should not ignore magic when the last thing assigned
+# was a glob
+$c = *strat;
+$s = $c;
+ok_string $s, *strat, 1, 1;
+
+
 # adapted from Tie::Counter by Abigail
 package Tie::Monitor;
 
diff -Nurp blead-77362-glob2lv9.tied/t/op/tie_fetch_count.t blead-77362-glob2lv10.glob-assign-and-magick/t/op/tie_fetch_count.t
--- blead-77362-glob2lv9.tied/t/op/tie_fetch_count.t	2010-08-26 06:18:49.000000000 -0700
+++ blead-77362-glob2lv10.glob-assign-and-magick/t/op/tie_fetch_count.t	2010-08-28 09:42:40.000000000 -0700
@@ -163,7 +163,7 @@ tie my $var3 => 'main', {};
 $dummy  = %$var3        ; check_count '%{}';
 {
     no strict 'refs';
-    tie my $var4 => 'main', **;
+    tie my $var4 => 'main', \**;
     $dummy  = *$var4        ; check_count '*{}';
 }
 
@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 25, 2010

From @cpansprout

On Sun Aug 29 13​:53​:25 2010, sprout wrote​:

On Aug 29, 2010, at 1​:48 PM, Father Chrysostomos wrote​:

#!perl -l
sub TIESCALAR{bless[]}
sub STORE{}
sub FETCH{1}
tie my $t, "";
$t = *foo;
$x = $t;
print $x; # prints *main​::foo

This patch won’t apply without the one for bug #77362 applied first.

If the patch for bug #77496 is not applied first, too, this one will
cause test failures, as it triggers that bug.

This modifies a test in t/op/tie_fetch_count.t, which currently relies
on this bug. *{} is another one of those operators that can return its
operand, like || and &&.

Applied as 5cf4b25 with modifications​: tie_fetch_count.t no
longer needs adjustment. pp_rv2gv needs to call sv_setsv_flags without
SV_GMAGIC (it was exploiting this bug).

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 25, 2010

From [Unknown Contact. See original ticket]

On Sun Aug 29 13​:53​:25 2010, sprout wrote​:

On Aug 29, 2010, at 1​:48 PM, Father Chrysostomos wrote​:

#!perl -l
sub TIESCALAR{bless[]}
sub STORE{}
sub FETCH{1}
tie my $t, "";
$t = *foo;
$x = $t;
print $x; # prints *main​::foo

This patch won’t apply without the one for bug #77362 applied first.

If the patch for bug #77496 is not applied first, too, this one will
cause test failures, as it triggers that bug.

This modifies a test in t/op/tie_fetch_count.t, which currently relies
on this bug. *{} is another one of those operators that can return its
operand, like || and &&.

Applied as 5cf4b25 with modifications​: tie_fetch_count.t no
longer needs adjustment. pp_rv2gv needs to call sv_setsv_flags without
SV_GMAGIC (it was exploiting this bug).

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 25, 2010

@cpansprout - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.