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

[Regression] Re-opening scalar handles breaks on 5.16.0 #12204

Closed
p5pRT opened this issue Jun 20, 2012 · 11 comments
Closed

[Regression] Re-opening scalar handles breaks on 5.16.0 #12204

p5pRT opened this issue Jun 20, 2012 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 20, 2012

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

Searchable as RT113764$

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2012

From @Leont

This is a bug report for perl from fawaka@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.16.0.


The following piece of code works fine on 5.14 and 5.12 (and
presumably on 5.8 and 5.10 too), but fails on 5.16. This breaks at
least one of my CPAN modules​:

open FILE, '>', \my $content or die "Couldn't open scalar filehandle";
open my $fh, ">&=FILE" or die "Couldn't open​: $!";
print $fh "Foo-Bar\n";
close $fh;
close FILE;
print $content;



Flags​:
  category=core
  severity=medium


Site configuration information for perl 5.16.0​:

Configured by leon at Mon May 21 12​:51​:40 CEST 2012.

Summary of my perl5 (revision 5 version 16 subversion 0) configuration​:

  Platform​:
  osname=linux, osvers=3.0.0-19-generic, archname=x86_64-linux-thread-multi
  uname='linux leon-laptop 3.0.0-19-generic #33-ubuntu smp thu apr
19 19​:05​:14 utc 2012 x86_64 x86_64 x86_64 gnulinux '
  config_args='-de
-Dprefix=/home/leon/perl5/perlbrew/perls/perl-5.16.0 -Dusethreads
-Dusesphplib'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
  optimize='-O2',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.6.1', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
  libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
  libc=, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.13'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'

Locally applied patches​:


@​INC for perl 5.16.0​:
  /home/leon/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/x86_64-linux-thread-multi
  /home/leon/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0
  /home/leon/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/x86_64-linux-thread-multi
  /home/leon/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0
  .


Environment for perl 5.16.0​:
  HOME=/home/leon
  LANG=en_US.utf8
  LANGUAGE=en_US​:en_GB​:en
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/home/leon/perl5/perlbrew/bin​:/home/leon/perl5/perlbrew/perls/perl-5.16.0/bin​:/home/leon/bin​:/usr/lib/lightdm/lightdm​:/usr/local/sbin​:/usr/local/bin​:/usr/sbin​:/usr/bin​:/sbin​:/bin​:/usr/games
  PERLBREW_HOME=/home/leon/.perlbrew
  PERLBREW_PATH=/home/leon/perl5/perlbrew/bin​:/home/leon/perl5/perlbrew/perls/perl-5.16.0/bin
  PERLBREW_PERL=perl-5.16.0
  PERLBREW_ROOT=/home/leon/perl5/perlbrew
  PERLBREW_VERSION=0.25
  PERL_BADLANG (unset)
  SHELL=/bin/

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2012

From @jkeenan

On Wed Jun 20 13​:02​:53 2012, LeonT wrote​:

This is a bug report for perl from fawaka@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.16.0.

-----------------------------------------------------------------

The following piece of code works fine on 5.14 and 5.12 (and
presumably on 5.8 and 5.10 too), but fails on 5.16. This breaks at
least one of my CPAN modules​:

open FILE, '>', \my $content or die "Couldn't open scalar filehandle";
open my $fh, ">&=FILE" or die "Couldn't open​: $!";
print $fh "Foo-Bar\n";
close $fh;
close FILE;
print $content;

Confirmed.

#####
$ /usr/bin/perl --version | head -2 | tail -1
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi

$ /usr/bin/perl -Mstrict -w 113764.pl
Foo-Bar

$ /usr/local/bin/perl5.12.0 -Mstrict -w 113764.pl
Foo-Bar

$ perl --version | head -2 | tail -1
This is perl 5, version 16, subversion 0 (v5.16.0) built for i686-linux

$ perl -Mstrict -w 113764.pl
Use of uninitialized value $content in print at 113764.pl line 6.
#####

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 20, 2012

From @doy

On Wed, Jun 20, 2012 at 01​:02​:53PM -0700, Leon Timmermans wrote​:

The following piece of code works fine on 5.14 and 5.12 (and
presumably on 5.8 and 5.10 too), but fails on 5.16. This breaks at
least one of my CPAN modules​:

open FILE, '>', \my $content or die "Couldn't open scalar filehandle";
open my $fh, ">&=FILE" or die "Couldn't open​: $!";
print $fh "Foo-Bar\n";
close $fh;
close FILE;
print $content;

49b69fb is the first bad commit
commit 49b69fb
Author​: Father Chrysostomos <sprout@​cpan.org>
Date​: Mon May 7 20​:43​:18 2012 -0700

  [perl #112780] Don’t set cloned in-memory handles to ""
 
  PerlIO​::scalar’s dup function (PerlIOScalar_dup) calls the base imple-
  mentation (PerlIOBase_dup), which pushes the scalar layer on to the
  new file handle.
 
  When the scalar layer is pushed, if the mode is ">" then
  PerlIOScalar_pushed sets the scalar to the empty string. If it is
  already a string, it does this simply by setting SvCUR to 0, without
  touching the string buffer.
 
  The upshot of this is that newly-cloned in-memory handles turn into
  the empty string, as in this example​:
 
  use threads;
  my $str = '';
  open my $fh, ">", \$str;
  $str = 'a';
  async {
  warn $str; # something's wrong
  }->join;
 
  This has probably always been this way.
 
  The test suite for MSCHWERN/Test-Simple-1.005000_005.tar.gz does some-
  thing similar to this​:
 
  use threads;
  my $str = '';
  open my $fh, ">", \$str;
  print $fh "a";
  async {
  print $fh "b";
  warn $str; # "ab" expected, but 5.15.7-9 gives "\0b"
  }->join;
 
  What was happening before commit b659727 was that two bugs were can-
  celling each other out​: $str would be "" when the new thread started,
  but with a string buffer containing "a" beyond the end of the string
  and $fh remembering 1 as its position. The bug fixed by b659727 was
  that writing past the end of a string through a filehandle was leaving
  junk (whatever was in memory already) in the intervening space between
  the old end of string and the beginning of what was being written to
  the string. This allowed "" to turn magically into "ab" when "b" was
  written one character past the end of the string. Commit b659727
  started zeroing out the intervening space in that case, causing the
  cloning bug to rear its head.
 
  This commit solves the problem by hiding the scalar temporarily
  in PerlIOScalar_dup so that PerlIOScalar_pushed won’t be able to
  modify it.
 
  Should PerlIOScalar_pushed stop clobbering the string and should
  PerlIOScalar_open do it instead? Perhaps. But that would be a bigger
  change, and we are supposed to be in code freeze right now.

:040000 040000 c6b08745fccce9963ab16647a41393f42e80484b 95e4780e1934da4e386690b2d18dee62515ca03b M ext
bisect run success
That took 1485 seconds

-doy

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2012

From @cpansprout

Fixed in commit 7b3cf1c.

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2012

From [Unknown Contact. See original ticket]

Fixed in commit 7b3cf1c.

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2012

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

@p5pRT p5pRT closed this as completed Jun 21, 2012
@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2012

From @Leont

On Thu, Jun 21, 2012 at 8​:55 AM, Father Chrysostomos via RT
<perlbug-comment@​perl.org> wrote​:

Fixed in commit 7b3cf1c.

Can I hereby nominate this to be cherry-picked for 5.16.1?

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @rurban

On Thu, Jun 21, 2012 at 7​:35 AM, Leon Timmermans <fawaka@​gmail.com> wrote​:

On Thu, Jun 21, 2012 at 8​:55 AM, Father Chrysostomos via RT
<perlbug-comment@​perl.org> wrote​:

Fixed in commit 7b3cf1c.

Can I hereby nominate this to be cherry-picked for 5.16.1?

I love you. Both.

I had the same regression in the compiler testsuite and thought for the whole
last year it was me, but couldn't find any bug. It's gone, __DATA__ handles
will work again.
Thanks
--
Reini Urban
http​://cpanel.net/   http​://www.perl-compiler.org/

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2012

From @rjbs

* Reini Urban <rurban@​x-ray.at> [2012-06-21T20​:36​:15]

On Thu, Jun 21, 2012 at 7​:35 AM, Leon Timmermans <fawaka@​gmail.com> wrote​:

On Thu, Jun 21, 2012 at 8​:55 AM, Father Chrysostomos via RT
<perlbug-comment@​perl.org> wrote​:

Fixed in commit 7b3cf1c.

Can I hereby nominate this to be cherry-picked for 5.16.1?

I love you. Both.

If I say yes, do I get love, too? :-)

Yes, I agree. I'll be picking it as soon as camel is up again...

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2012

From @rurban

On Thu, Jun 21, 2012 at 7​:47 PM, Ricardo Signes
<perl.p5p@​rjbs.manxome.org> wrote​:

* Reini Urban <rurban@​x-ray.at> [2012-06-21T20​:36​:15]

On Thu, Jun 21, 2012 at 7​:35 AM, Leon Timmermans <fawaka@​gmail.com> wrote​:

On Thu, Jun 21, 2012 at 8​:55 AM, Father Chrysostomos via RT
<perlbug-comment@​perl.org> wrote​:

Fixed in commit 7b3cf1c.

Can I hereby nominate this to be cherry-picked for 5.16.1?

I love you. Both.

If I say yes, do I get love, too? :-)

I even blogged about my love to you.
  http​://blogs.perl.org/users/rurban/2012/06/my-yapcna-2012-madison.html
"He has humor. I like this guy"
Really.
--
Reini Urban
http​://cpanel.net/   http​://www.perl-compiler.org/

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

No branches or pull requests

1 participant