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

refaliasing does not work #16701

Closed
p5pRT opened this issue Sep 22, 2018 · 11 comments
Closed

refaliasing does not work #16701

p5pRT opened this issue Sep 22, 2018 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 22, 2018

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

Searchable as RT133538$

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2018

From @KES777

Created by @KES777

https://perldoc.perl.org/perlref.html#Making-References

my @​list = ( 1, 2, 3 );

# Test 1
my %hash = ();
{
  \( @​hash{qw/ a b c /} ) = \(@​list);
}
print %hash; # abc

values are destroed from hash when we leave the block

It is same for this​:

my %hash = ();
{
  \( @​hash{qw/ a b c /} ) = (\$list[0], \$list[1], \$list[2]);
}
print %hash; # abc

But individual aliasing works fine​:
# Test 6
%hash = ();
{
  \$hash{a} = \$list[0];
  \$hash{b} = \$list[1];
  \$hash{c} = \$list[2];
}
print "Test 6​: @​{[ %hash ]}\n"; # a 1 b 2 c 3

See attached file for full test list

Perl Info

Flags:
    category=core
    severity=critical

Site configuration information for perl 5.24.1:

Configured by kes at Mon May  7 20:59:03 EEST 2018.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=4.13.0-26-generic, archname=x86_64-linux
    uname='linux work 4.13.0-26-generic #29~16.04.2-ubuntu smp tue jan 9 22:00:44 utc 2018 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.24.1 -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.24.1/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='5.4.0 20160609', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    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-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.23.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.23'
  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-strong'

Locally applied patches:
    Devel::PatchPerl 1.38


@INC for perl 5.24.1:
    /home/kes/work/projects/tucha/monkeyman/lib
    /home/kes/work/projects/tucha/monkeyman/local/lib/perl5/5.24.1/x86_64-linux
    /home/kes/work/projects/tucha/monkeyman/local/lib/perl5/5.24.1
    /home/kes/work/projects/tucha/monkeyman/local/lib/perl5/x86_64-linux
    /home/kes/work/projects/tucha/monkeyman/local/lib/perl5
    /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1/x86_64-linux
    /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1
    /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux
    /home/kes/perl5/perlbrew/perls/perl-5.24.1/lib/5.24.1


Environment for perl 5.24.1:
    HOME=/home/kes
    LANG=en_US.UTF-8
    LANGUAGE=en
    LC_ADDRESS=uk_UA.UTF-8
    LC_IDENTIFICATION=uk_UA.UTF-8
    LC_MEASUREMENT=uk_UA.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_MONETARY=uk_UA.UTF-8
    LC_NAME=uk_UA.UTF-8
    LC_NUMERIC=uk_UA.UTF-8
    LC_PAPER=uk_UA.UTF-8
    LC_TELEPHONE=uk_UA.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.1/bin:/home/kes/bin:/home/kes/work/projects/tucha/monkeyman/local/bin:/home/kes/work/projects/safevpn/repo2/local/bin:/home/kes/bin:/home/kes/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    PERL5DB=use DB::Hooks qw'::Terminal NonStop'
    PERL5LIB=/home/kes/work/projects/tucha/monkeyman/lib:/home/kes/work/projects/tucha/monkeyman/local/lib/perl5
    PERLBREW=command perlbrew
    PERLBREW_BASHRC_VERSION=0.78
    PERLBREW_HOME=/home/kes/.perlbrew
    PERLBREW_MANPATH=/home/kes/perl5/perlbrew/perls/perl-5.24.1/man
    PERLBREW_PATH=/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.24.1/bin
    PERLBREW_PERL=perl-5.24.1
    PERLBREW_ROOT=/home/kes/perl5/perlbrew
    PERLBREW_VERSION=0.78
    PERLDB_OPTS=white_box
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2018

From @KES777

t.pl

@p5pRT
Copy link
Author

p5pRT commented Sep 22, 2018

From @KES777

this is also true on 5.29.3

@p5pRT
Copy link
Author

p5pRT commented Nov 1, 2018

From @jkeenan

On Sat, 22 Sep 2018 09​:56​:45 GMT, kes-kes@​yandex.ru wrote​:

Reply-To​: kes-kes@​yandex.ru
Message-Id​: <5.24.1_18064_1537609447@​work>
To​: perlbug@​perl.org
Subject​: refaliasing does not work
From​: kes-kes@​yandex.ru
Cc​: kes-kes@​yandex.ru

This is a bug report for perl from kes-kes@​yandex.ru,
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
[Please describe your issue here]

https://perldoc.perl.org/perlref.html#Making-References

my @​list = ( 1, 2, 3 );

# Test 1
my %hash = ();
{
\( @​hash{qw/ a b c /} ) = \(@​list);
}
print %hash; # abc

values are destroed from hash when we leave the block

It is same for this​:

my %hash = ();
{
\( @​hash{qw/ a b c /} ) = (\$list[0], \$list[1], \$list[2]);
}
print %hash; # abc

But individual aliasing works fine​:
# Test 6
%hash = ();
{
\$hash{a} = \$list[0];
\$hash{b} = \$list[1];
\$hash{c} = \$list[2];
}
print "Test 6​: @​{[ %hash ]}\n"; # a 1 b 2 c 3

See attached file for full test list

Do we have a similar problem for array slice assignment with refaliasing within a block?

See attachment 133538-refalaising-array-slice.pl.

#####
$> perl 133538-refalaising-array-slice.pl
ok 1 - simple array slice assignment
ok 2 - array slice assignment with refaliasing
ok 3 - simple array slice assignment within block
not ok 4 - array slice assignment with refaliasing within block
# Failed test 'array slice assignment with refaliasing within block'
# at 133538-refalaising-array-slice.pl line 25.
# Structures begin differing at​:
# $got->[4] = undef
# $expected->[4] = '1'
Got​:
$VAR1 = [undef,undef,undef,undef,undef,undef,undef];
Expected​:
$VAR1 = [undef,undef,undef,undef,1,2,3];
1..4
# Looks like you failed 1 test of 4.
#####

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Nov 1, 2018

@p5pRT
Copy link
Author

p5pRT commented Nov 1, 2018

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

@p5pRT
Copy link
Author

p5pRT commented Nov 5, 2018

From @iabyn

On Sat, Sep 22, 2018 at 02​:56​:46AM -0700, KES (via RT) wrote​:

my @​list = ( 1, 2, 3 );

# Test 1
my %hash = ();
{
\( @​hash{qw/ a b c /} ) = \(@​list);
}
print %hash; # abc

values are destroed from hash when we leave the block

Now fixed in blead with the following commit​:

commit b97fe86
Author​: David Mitchell <davem@​iabyn.com>
AuthorDate​: Mon Nov 5 12​:29​:27 2018 +0000
Commit​: David Mitchell <davem@​iabyn.com>
CommitDate​: Mon Nov 5 12​:29​:27 2018 +0000

  Don't localise array / hash slice ref assignment
 
  RT #133538
 
  The experimental ref assignment aliasing feature, when applied to
  array or hash slices, was treating the slice as if it was always localized;
  e.g.
 
  \(@​a[3,5,7]) = \(....);
 
  was being interpreted as
 
  local \(@​a[3,5,7]) = \(....);
 
  The fix is simple​: check for the OPpLVAL_INTRO flag actually being set
  on the op, rather than unconditionally localising the array/hash
  elements.

--
"There's something wrong with our bloody ships today, Chatfield."
  -- Admiral Beatty at the Battle of Jutland, 31st May 1916.

@p5pRT
Copy link
Author

p5pRT commented Nov 5, 2018

@iabyn - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Nov 5, 2018

From @jkeenan

On Mon, 05 Nov 2018 12​:39​:29 GMT, davem wrote​:

On Sat, Sep 22, 2018 at 02​:56​:46AM -0700, KES (via RT) wrote​:

my @​list = ( 1, 2, 3 );

# Test 1
my %hash = ();
{
\( @​hash{qw/ a b c /} ) = \(@​list);
}
print %hash; # abc

values are destroed from hash when we leave the block

Now fixed in blead with the following commit​:

commit b97fe86
Author​: David Mitchell <davem@​iabyn.com>
AuthorDate​: Mon Nov 5 12​:29​:27 2018 +0000
Commit​: David Mitchell <davem@​iabyn.com>
CommitDate​: Mon Nov 5 12​:29​:27 2018 +0000

Don't localise array / hash slice ref assignment

RT #133538

The experimental ref assignment aliasing feature, when applied to
array or hash slices, was treating the slice as if it was always
localized;
e.g.

\(@​a[3,5,7]) = \(....);

was being interpreted as

local \(@​a[3,5,7]) = \(....);

The fix is simple​: check for the OPpLVAL_INTRO flag actually being set
on the op, rather than unconditionally localising the array/hash
elements.

Works on my test files. Thanks.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented May 22, 2019

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.30.0, this and 160 other issues have been
resolved.

Perl 5.30.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.30.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 22, 2019

@khwilliamson - Status changed from 'pending release' to 'resolved'

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