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

bless to a string ending :: interferes with ISA lookup after typeglob aliasing #11244

Closed
p5pRT opened this issue Apr 9, 2011 · 9 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Apr 9, 2011

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

Searchable as RT88132$

@p5pRT
Copy link
Author

p5pRT commented Apr 9, 2011

From @nwc10

Created by @nwc10

$ cat package_corner_case.pl
#!/usr/bin/perl -w
use strict;

my $tail = shift;
$tail = 'inner' unless defined $tail;

@​left​::ISA = "outer​::$tail";
@​right​::ISA = "clone​::$tail";

*clone​:: = *outer​:: ;

eval "package outer​::$tail; 1" or die $@​;

print "ok 1", "\n" if left->isa("clone​::$tail");
print "ok 2", "\n" if right->isa("outer​::$tail");

print "ok 3", "\n" if right->isa("clone​::$tail");
print "ok 4", "\n" if left->isa("outer​::$tail");

__END__
$ ~/Sandpit/589/bin/perl5.8.9 package_corner_case.pl inner
ok 1
ok 2
ok 3
ok 4
$ ~/Sandpit/589/bin/perl5.8.9 package_corner_case.pl inner​::
ok 1
ok 2
ok 3
ok 4
$ ./perl -Ilib package_corner_case.pl inner
ok 1
ok 2
ok 3
ok 4
$ ./perl -Ilib package_corner_case.pl inner​::
ok 1
ok 3
ok 4

Very obscure, admittedly, and probably not anything anyone is relying on,
but this is a behaviour regression since 5.8.x, and relates to the rather
ugly emergent behaviour of Perl_gv_fetch_pvnflags() as called by
Perl_gv_stashpvn()

I don't think that the right fix is "simply to *copy*" the logic for
mro_package_moved() out to Perl_gv_stashpvn(). The right fix, to me, is
changing the parsing logic in Perl_gv_fetch_pvnflags() so that the relevant
code in the single location is always called correctly.

Nicholas Clark

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.14.0:

Configured by nick at Sat Apr  9 10:30:34 BST 2011.

Summary of my perl5 (revision 5 version 14 subversion 0) configuration:
  Derived from: d1ef1aa80747cb421af3e87bd1944a13a5fb2627
  Platform:
    osname=linux, osvers=2.6.35.4, archname=x86_64-linux
    uname='linux eris 2.6.35.4 #4 smp tue sep 21 09:54:22 bst 2010 x86_64 gnulinux '
    config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list=  -Dinc_version_list_init=0 -DDEBUGGING -Doptimize=-Os -Uusethreads -Uuselongdouble -Uuse64bitall -Uusemymalloc -Duseperlio -Dprefix=~/Sandpit/snap5.9.x-v5.13.11-407-gd1ef1aa -Uusevendorprefix -Uvendorprefix=~/Sandpit/snap5.9.x-v5.13.11-407-gd1ef1aa -Dinstallman1dir=none -Dinstallman3dir=none -Uuserelocatableinc -Umad -de'
    hint=previous, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='4.3.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='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector'

Locally applied patches:
    RC0


@INC for perl 5.14.0:
    lib
    /home/nick/Sandpit/snap5.9.x-v5.13.11-379-g801eb08/lib/perl5/site_perl/5.14.0/x86_64-linux
    /home/nick/Sandpit/snap5.9.x-v5.13.11-379-g801eb08/lib/perl5/site_perl/5.14.0
    /home/nick/Sandpit/snap5.9.x-v5.13.11-379-g801eb08/lib/perl5/5.14.0/x86_64-linux
    /home/nick/Sandpit/snap5.9.x-v5.13.11-379-g801eb08/lib/perl5/5.14.0
    .


Environment for perl 5.14.0:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2011

From @cpansprout

On Sat Apr 09 03​:59​:05 2011, nicholas wrote​:

$ cat package_corner_case.pl
#!/usr/bin/perl -w
use strict;

my $tail = shift;
$tail = 'inner' unless defined $tail;

@​left​::ISA = "outer​::$tail";
@​right​::ISA = "clone​::$tail";

*clone​:: = *outer​:: ;

eval "package outer​::$tail; 1" or die $@​;

print "ok 1", "\n" if left->isa("clone​::$tail");
print "ok 2", "\n" if right->isa("outer​::$tail");

print "ok 3", "\n" if right->isa("clone​::$tail");
print "ok 4", "\n" if left->isa("outer​::$tail");

That looks awfully familiar. :-)

__END__
$ ~/Sandpit/589/bin/perl5.8.9 package_corner_case.pl inner
ok 1
ok 2
ok 3
ok 4
$ ~/Sandpit/589/bin/perl5.8.9 package_corner_case.pl inner​::
ok 1
ok 2
ok 3
ok 4
$ ./perl -Ilib package_corner_case.pl inner
ok 1
ok 2
ok 3
ok 4
$ ./perl -Ilib package_corner_case.pl inner​::
ok 1
ok 3
ok 4

Very obscure, admittedly, and probably not anything anyone is relying
on,
but this is a behaviour regression since 5.8.x,

I’ve been trying hard to fix all regressions introduced since 5.8.8.
That’s the whole reason I started working on perl. So I would *very*
much like it if this could be made a 5.14 blocker. (I was hoping 5.14
could be the version that finally fixes all the bugs that 5.10 introduced.)

and relates to the
rather
ugly emergent behaviour of Perl_gv_fetch_pvnflags() as called by
Perl_gv_stashpvn()

I don't think that the right fix is "simply to *copy*" the logic for
mro_package_moved() out to Perl_gv_stashpvn(). The right fix, to me,
is
changing the parsing logic in Perl_gv_fetch_pvnflags() so that the
relevant
code in the single location is always called correctly.

Changing the parsing seems the sanest approach. I think changing

  name_cursor++;
  name = name_cursor;

to

  name = name_cursor + 1;

would work. But I need a day or three to think it through.

We might instead be able simply to add the name to the stash later in
gv_fetchpvn_flags if the full glob name ends with :​:. But that might not
fix regressions with regard to *foo​::​::​:: assignments (if there are any).

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2011

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

@p5pRT
Copy link
Author

p5pRT commented Apr 11, 2011

From @cpansprout

On Sun Apr 10 21​:55​:11 2011, sprout wrote​:

On Sat Apr 09 03​:59​:05 2011, nicholas wrote​:

$ cat package_corner_case.pl
#!/usr/bin/perl -w
use strict;

my $tail = shift;
$tail = 'inner' unless defined $tail;

@​left​::ISA = "outer​::$tail";
@​right​::ISA = "clone​::$tail";

*clone​:: = *outer​:: ;

eval "package outer​::$tail; 1" or die $@​;

print "ok 1", "\n" if left->isa("clone​::$tail");
print "ok 2", "\n" if right->isa("outer​::$tail");

print "ok 3", "\n" if right->isa("clone​::$tail");
print "ok 4", "\n" if left->isa("outer​::$tail");

That looks awfully familiar. :-)

__END__
$ ~/Sandpit/589/bin/perl5.8.9 package_corner_case.pl inner
ok 1
ok 2
ok 3
ok 4
$ ~/Sandpit/589/bin/perl5.8.9 package_corner_case.pl inner​::
ok 1
ok 2
ok 3
ok 4
$ ./perl -Ilib package_corner_case.pl inner
ok 1
ok 2
ok 3
ok 4
$ ./perl -Ilib package_corner_case.pl inner​::
ok 1
ok 3
ok 4

Very obscure, admittedly, and probably not anything anyone is relying
on,
but this is a behaviour regression since 5.8.x,

I’ve been trying hard to fix all regressions introduced since 5.8.8.
That’s the whole reason I started working on perl. So I would *very*
much like it if this could be made a 5.14 blocker. (I was hoping 5.14
could be the version that finally fixes all the bugs that 5.10
introduced.)

I forgot to add​: Since this is such an obscure case, I think fixing it
is perfectly safe.

@p5pRT
Copy link
Author

p5pRT commented Apr 12, 2011

From @obra

On Sun, Apr 10, 2011 at 09​:55​:12PM -0700, Father Chrysostomos via RT wrote​:

On Sat Apr 09 03​:59​:05 2011, nicholas wrote​:

I???ve been trying hard to fix all regressions introduced since 5.8.8.
That???s the whole reason I started working on perl. So I would *very*
much like it if this could be made a 5.14 blocker. (I was hoping 5.14
could be the version that finally fixes all the bugs that 5.10 introduced.)

I'm not sure we'll get all the way to _that_ lofty goal for 5.14, but
I'm willing to make this one a blocker for now. Please go ahead :)

and relates to the
rather
ugly emergent behaviour of Perl_gv_fetch_pvnflags() as called by
Perl_gv_stashpvn()

I don't think that the right fix is "simply to *copy*" the logic for
mro_package_moved() out to Perl_gv_stashpvn(). The right fix, to me,
is
changing the parsing logic in Perl_gv_fetch_pvnflags() so that the
relevant
code in the single location is always called correctly.

Changing the parsing seems the sanest approach. I think changing

    name\_cursor\+\+;
    name = name\_cursor;

to

    name = name\_cursor \+ 1;

would work. But I need a day or three to think it through.

We might instead be able simply to add the name to the stash later in
gv_fetchpvn_flags if the full glob name ends with :​:. But that might not
fix regressions with regard to *foo​::​::​:: assignments (if there are any).

--

@p5pRT
Copy link
Author

p5pRT commented Apr 13, 2011

From @cpansprout

On Sun Apr 10 21​:55​:11 2011, sprout wrote​:

Changing the parsing seems the sanest approach. I think changing

    name\_cursor\+\+;
    name = name\_cursor;

to

    name = name\_cursor \+ 1;

would work.

That seemed the best approach, except it required a tweak to the
if(len>0) condition as well.

I’ve just applied my change as commit 088225f.

@p5pRT
Copy link
Author

p5pRT commented Apr 13, 2011

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

@p5pRT p5pRT closed this as completed Apr 13, 2011
@p5pRT
Copy link
Author

p5pRT commented Apr 13, 2011

From @nwc10

On Sun, Apr 10, 2011 at 09​:55​:12PM -0700, Father Chrysostomos via RT wrote​:

On Sat Apr 09 03​:59​:05 2011, nicholas wrote​:

print "ok 1", "\n" if left->isa("clone​::$tail");
print "ok 2", "\n" if right->isa("outer​::$tail");

print "ok 3", "\n" if right->isa("clone​::$tail");
print "ok 4", "\n" if left->isa("outer​::$tail");

That looks awfully familiar. :-)

Yes, although I did wonder why you'd only output 2 of the 4 possible
combinations in your test programs. I see that your new commit does all 4.

Very obscure, admittedly, and probably not anything anyone is relying
on,
but this is a behaviour regression since 5.8.x,

and relates to the
rather
ugly emergent behaviour of Perl_gv_fetch_pvnflags() as called by
Perl_gv_stashpvn()

I don't think that the right fix is "simply to *copy*" the logic for
mro_package_moved() out to Perl_gv_stashpvn(). The right fix, to me,
is
changing the parsing logic in Perl_gv_fetch_pvnflags() so that the
relevant
code in the single location is always called correctly.

Changing the parsing seems the sanest approach. I think changing

    name\_cursor\+\+;
    name = name\_cursor;

to

    name = name\_cursor \+ 1;

would work. But I need a day or three to think it through.

That was my roughly thought on the way to go.

We might instead be able simply to add the name to the stash later in
gv_fetchpvn_flags if the full glob name ends with :​:. But that might not
fix regressions with regard to *foo​::​::​:: assignments (if there are any).

On Wed, Apr 13, 2011 at 09​:51​:00AM -0700, Father Chrysostomos via RT wrote​:

That seemed the best approach, except it required a tweak to the
if(len>0) condition as well.

but I didn't know that part.

As you note in 088225f's commit message, it will also change the
structures generated for *foo​::​::​::, which was why I asked on list a few
days ago

  Is it documented anywhere how the package names in

  package a​::​::​::b;
  $o = bless [], "c​::​::​::d";

  are to be parsed?

and everyone who replied stated that there wasn't.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Apr 16, 2011

From @cpansprout

On Wed Apr 13 09​:50​:59 2011, sprout wrote​:

On Sun Apr 10 21​:55​:11 2011, sprout wrote​:

Changing the parsing seems the sanest approach. I think changing

    name\_cursor\+\+;
    name = name\_cursor;

to

    name = name\_cursor \+ 1;

would work.

That seemed the best approach, except it required a tweak to the
if(len>0) condition as well.

I’ve just applied my change as commit 088225f.

That proved to be insufficient, as the regression still existed in some
cases. So I have fixed it now (hopefully) with commit 1f656fc.

Since it was intertwined with the bug that has been making RDF​::Trine
crash (UNIVERSAL​::isa("​:","foo") crashing when *​: exists), I have ended
up fixing RDF​::Trine as well.

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