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

set_mro too lazy, permits unmergeable inheritance #15406

Open
p5pRT opened this issue Jun 23, 2016 · 2 comments
Open

set_mro too lazy, permits unmergeable inheritance #15406

p5pRT opened this issue Jun 23, 2016 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 23, 2016

Migrated from rt.perl.org#128465 (status was 'new')

Searchable as RT128465$

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2016

From @kentfredric

Created by @kentfredric

calling set_mro( $Package, 'c3' ) where $Package pertains to a class with an unmergeable inheritance.

This means the call succeeds, but the modified class will then die fatally
as soon as somebody invokes "can" or "mro​::get_linear_isa"

Attached is a test that demonstrates that set_mro does not fail as expected,

but does fail upon calling ->can()

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.25.1:

Configured by kent at Sat May 21 11:49:03 NZST 2016.

Summary of my perl5 (revision 5 version 25 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=4.4.0-gentoo-r1, archname=x86_64-linux
    uname='linux katipo2 4.4.0-gentoo-r1 #33 smp preempt fri jan 29 01:03:50 nzdt 2016 x86_64 intel(r) core(tm) i5-2410m cpu @ 2.30ghz genuineintel gnulinux '
    config_args='-de -Dprefix=/home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc -Doptimize= -fno-stack-protector -O3 -march=native -mtune=native -Dman1dir=none -Dman3dir=none -Dusedevel -Accflags= -fno-stack-protector -DPERL_HASH_FUNC_SDBM -DPERL_DISABLE_PMC -Aldflags= -fno-stack-protector -Aeval:scriptdir=/home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/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 ='-fno-stack-protector -DPERL_HASH_FUNC_SDBM -DPERL_DISABLE_PMC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize=' -fno-stack-protector -O3 -march=native -mtune=native',
    cppflags='-fno-stack-protector -DPERL_HASH_FUNC_SDBM -DPERL_DISABLE_PMC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion='', gccversion='5.3.0', 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 ='  -fno-stack-protector -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include-fixed /usr/lib /usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    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  -fno-stack-protector -O3 -march=native -mtune=native -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.25.1:
    /home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/lib/site_perl/5.25.1/x86_64-linux
    /home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/lib/site_perl/5.25.1
    /home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/lib/5.25.1/x86_64-linux
    /home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/lib/5.25.1
    .


Environment for perl 5.25.1:
    HOME=/home/kent
    LANG=en_NZ.UTF8
    LANGUAGE (unset)
    LC_CTYPE=en_NZ.UTF8
    LC_TIME=en_NZ.UTF8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/kent/perl5/perlbrew/bin:/home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/bin:/home/kent/perl5/perlbrew/bin:/home/kent/perl5/perlbrew/perls/5.22.1-nossp-sdbm-nopmc/bin:/home/kent/.perl6/2013.04/bin:/home/kent/.gem/ruby/1.8/bin/:/home/kent/.rvm/gems/ruby-2.1.2/bin:/home/kent/.rvm/gems/ruby-2.1.2@global/bin:/home/kent/.rvm/rubies/ruby-2.1.2/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/5.3.0:/usr/games/bin:/home/kent/.rvm/bin:/home/kent/.rvm/bin
    PERL5LIB=
    PERLBREW_BASHRC_VERSION=0.74
    PERLBREW_HOME=/home/kent/.perlbrew
    PERLBREW_LIB=
    PERLBREW_MANPATH=/home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/man
    PERLBREW_PATH=/home/kent/perl5/perlbrew/bin:/home/kent/perl5/perlbrew/perls/5.25.1-nossp-sdbm-nopmc/bin
    PERLBREW_PERL=5.25.1-nossp-sdbm-nopmc
    PERLBREW_ROOT=/home/kent/perl5/perlbrew
    PERLBREW_VERSION=0.74
    PERL_BADLANG (unset)
    PERL_LOCAL_LIB_ROOT=
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2016

From @kentfredric

#!perl
use strict;
use warnings;
use Test​::More;

# Legal DFS structure.
@​My​::Example​::A​::ISA = ( 'My​::Example​::C', 'My​::Example​::B' );
@​My​::Example​::B​::ISA = ('My​::Example​::C');
@​My​::Example​::C​::ISA = ('My​::Example​::D');
@​My​::Example​::D​::ISA = ();

ok(
  eval {
  My​::Example​::A->can('foo');
  1;
  },
  "DFS structure is ok"
);

# Project 2 wants C3
use mro;
@​My​::Example​::E​::ISA = ('My​::Example​::A');

ok(
  !eval {
  mro​::set_mro( 'My​::Example​::E', 'c3' );
  1;
  },
  "Setting C3 on unmergable layout should fail"
);

local $@​;
ok(
  !eval {
  My​::Example​::E->can('foo');
  1;
  },
  "Calling a method with invalid MRO fails"
);

note $@​;

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

2 participants