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

Dumper loses blessedness from unreferenced scalars #14466

Open
p5pRT opened this issue Feb 3, 2015 · 3 comments
Open

Dumper loses blessedness from unreferenced scalars #14466

p5pRT opened this issue Feb 3, 2015 · 3 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Feb 3, 2015

Migrated from rt.perl.org#123721 (status was 'open')

Searchable as RT123721$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 3, 2015

From zefram@fysh.org

Created by zefram@fysh.org

$ perl -MData​::Dumper=Dumper -we '@​a=(3); bless \$a[0], "Foo"; print Dumper \$a[0]; print Dumper \@​a'
$VAR1 = bless( do{\(my $o = 3)}, 'Foo' );
$VAR1 = [
  3
  ];

Dumper is willing to show the blessedness of a scalar that it encounters
through a reference, but fails to show it if it encounters the scalar
as an array element. (Likewise a hash element.)

Due to Dumper displaying aliasing, it *can* end up representing the
blessedness of an array element, except that it actually screws up with
the aliasing expression. Whether the blessedness is represented depends
on the order in which parts of a data structure are encountered​:

$ perl -MData​::Dumper=Dumper -we '@​a=(3,0); $a[1] = \$a[0]; bless \$a[0], "Foo"; print Dumper \@​a'
$VAR1 = [
  3,
  \$VAR1->[0]
  ];

Blessed scalar comes before reference​: the blessing is not preserved,
but the aliasing is correct.

$ perl -MData​::Dumper=Dumper -we '@​a=(0,3); $a[0] = \$a[1]; bless \$a[1], "Foo"; print Dumper \@​a'
$VAR1 = [
  bless( do{\(my $o = 3)}, 'Foo' ),
  ${$VAR1->[0]}
  ];

Reference comes before blessed scalar​: the blessing is preserved, but
the expression used for the aliasing doesn't account for the copying
performed by the [...] array constructor.

Perl Info

Flags:
    category=library
    severity=low
    module=Data::Dumper

Site configuration information for perl 5.18.2:

Configured by root at Wed Mar 26 14:32:51 UTC 2014.

Summary of my perl5 (revision 5 version 18 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=3.2.0-4-amd64, archname=x86_64-linux-ld
    uname='linux ukmcwzefram.photobox.priv 3.2.0-4-amd64 #1 smp debian 3.2.54-2 x86_64 gnulinux '
    config_args='-des -Duseshrplib -Duse64bitint -Duselongdouble -Uusethreads -Uusemultiplicity -Dprefix=/opt/perl-5.18.2 -Dsiteprefix=/opt/perl-5.18.2 -Dvendorprefix=/opt/perl-5.18.2/vendor -Doptimize=-ggdb -O3 -fbranch-target-load-optimize -fgcse-las -fgcse-sm -fipa-pta -floop-block -floop-interchange -floop-strip-mine -fmodulo-sched -fomit-frame-pointer -freorder-blocks-and-partition -fsched-spec-load -fsched-spec-load-dangerous -ftree-loop-distribution -Dcccdlflags=-fPIC -O3 -pipe'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-ggdb -O3 -fbranch-target-load-optimize -fgcse-las -fgcse-sm -fipa-pta -floop-block -floop-interchange -floop-strip-mine -fmodulo-sched -fomit-frame-pointer -freorder-blocks-and-partition -fsched-spec-load -fsched-spec-load-dangerous -ftree-loop-distribution',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.7.2', 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='long double', nvsize=16, Off_t='off_t', lseeksize=8
    alignbytes=16, 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 -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.17'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/perl-5.18.2/lib/5.18.2/x86_64-linux-ld/CORE'
    cccdlflags='-fPIC -O3 -pipe', lddlflags='-shared -ggdb -O3 -fbranch-target-load-optimize -fgcse-las -fgcse-sm -fipa-pta -floop-block -floop-interchange -floop-strip-mine -fmodulo-sched -fomit-frame-pointer -freorder-blocks-and-partition -fsched-spec-load -fsched-spec-load-dangerous -ftree-loop-distribution -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.18.2:
    /opt/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux-ld
    /opt/perl-5.18.2/lib/site_perl/5.18.2
    /opt/perl-5.18.2/vendor/lib/vendor_perl/5.18.2/x86_64-linux-ld
    /opt/perl-5.18.2/vendor/lib/vendor_perl/5.18.2
    /opt/perl-5.18.2/lib/5.18.2/x86_64-linux-ld
    /opt/perl-5.18.2/lib/5.18.2
    .


Environment for perl 5.18.2:
    HOME=/home/zefram
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/zefram/pub/x86_64-unknown-linux-gnu/bin:/home/zefram/pub/common/bin:/usr/bin:/bin:/usr/local/bin:/usr/games:/opt/babelhttpd-2.2.26/bin:/opt/babelhttpd-2.4.7/bin:/opt/geoip/bin:/opt/httpd/bin:/opt/perl/bin
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 26, 2015

From @tonycoz

On Tue Feb 03 03​:31​:55 2015, zefram@​fysh.org wrote​:

$ perl -MData​::Dumper=Dumper -we '@​a=(3); bless \$a[0], "Foo"; print
Dumper \$a[0]; print Dumper \@​a'
$VAR1 = bless( do{\(my $o = 3)}, 'Foo' );
$VAR1 = [
3
];

Similarly​:

$ ./perl -Ilib -MData​::Dumper -le '$x = 3; bless \$x, "Foo"; print Dumper($x)'
$VAR1 = 3;

Tony

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 26, 2015

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

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