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

Exporter does not work in multiple inheritance if not the first parent #9889

Closed
p5pRT opened this issue Sep 28, 2009 · 11 comments
Closed

Exporter does not work in multiple inheritance if not the first parent #9889

p5pRT opened this issue Sep 28, 2009 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 28, 2009

Migrated from rt.perl.org#69450 (status was 'rejected')

Searchable as RT69450$

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2009

From @jquelin

Created by @jquelin

check this little module that inherits from exporter and any other
module​:
===== BEGIN PASTE
$ cat Foo.pm
package Foo;
use parent qw{ IO​::Socket Exporter };
our @​EXPORT = qw{ $FOO };
our $FOO = 42;
1;
===== END PASTE

and here's a small script that just uses it​:
===== BEGIN PASTE
$ cat foo
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use Foo;
say $FOO;
===== END PASTE

note that exporter is not the first parent. in that case, running the
program fails​:
$ ./foo
Global symbol "$FOO" requires explicit package name at ./foo line 6.
Execution of ./foo aborted due to compilation errors.

but just change the order in use parent to read​:
  use parent qw{ Exporter IO​::Socket };

then the script is working correctly​:
$ ./foo
42

using base instead of parent does not change the problem, so it really
seems to be exporter-related.

this is with exporter 5.63.

jérôme

Perl Info

Flags:
    category=library
    severity=high
    module=Exporter

Site configuration information for perl 5.10.1:

Configured by Mandriva at Sun Sep 27 18:05:32 EDT 2009.

Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=2.6.22.12-server-1mdv, archname=x86_64-linux-thread-multi
    uname='linux klodia.mandriva.com 2.6.22.12-server-1mdv #1 smp tue nov 20 13:57:31 est 2007 x86_64 genuine intel(r) cpu 3.20ghz gnulinux '
    config_args='-des -Dinc_version_list=5.10.0 5.10.0/x86_64-linux-thread-multi 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.1 5.6.0 -Darchname=x86_64-linux -Dcc=x86_64-mandriva-linux-gnu-gcc -Doptimize=-O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -DDEBUGGING=-g -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dsitebin=/usr/local/bin -Dsiteman1dir=/usr/local/share/man/man1 -Dsiteman3dir=/usr/local/share/man/man3 -Dman3ext=3pm -Dcf_by=Mandriva -Dmyhostname=localhost -Dperladmin=root@localhost -Dcf_email=root@localhost -Dd_dosuid -Ud_csh -Duseshrplib -Duseithreads -Di_db -Di_ndbm -Di_gdbm'
    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='x86_64-mandriva-linux-gnu-gcc', 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 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.4.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='x86_64-mandriva-linux-gnu-gcc', ldflags =' -fstack-protector -L/usr/local/lib64'
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.10.1.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.10.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.10.1/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -L/usr/local/lib64'

Locally applied patches:
    Mandriva Linux patches


@INC for perl 5.10.1:
    /home/jquelin/lib/perl5
    /usr/lib/perl5/site_perl/5.10.1/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.10.1
    /usr/lib/perl5/vendor_perl/5.10.1/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.10.1
    /usr/lib/perl5/5.10.1/x86_64-linux-thread-multi
    /usr/lib/perl5/5.10.1
    /usr/lib/perl5/site_perl/5.10.0
    /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.10.0
    /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl
    .


Environment for perl 5.10.1:
    HOME=/home/jquelin
    LANG=fr_FR.UTF-8
    LANGUAGE=fr_FR.UTF-8:fr
    LC_ADDRESS=fr_FR.UTF-8
    LC_COLLATE=fr_FR.UTF-8
    LC_CTYPE=fr_FR.UTF-8
    LC_IDENTIFICATION=fr_FR.UTF-8
    LC_MEASUREMENT=fr_FR.UTF-8
    LC_MESSAGES=fr_FR.UTF-8
    LC_MONETARY=fr_FR.UTF-8
    LC_NAME=fr_FR.UTF-8
    LC_NUMERIC=fr_FR.UTF-8
    LC_PAPER=fr_FR.UTF-8
    LC_SOURCED=1
    LC_TELEPHONE=fr_FR.UTF-8
    LC_TIME=fr_FR.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/jquelin/bin:/home/jquelin/bin:/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/usr/lib/qt4/bin:/sbin:/usr/sbin:/usr/games:/sbin:/usr/sbin:/usr/games
    PERL5LIB=/home/jquelin/lib/perl5
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2009

From perl@profvince.com

using base instead of parent does not change the problem, so it really
seems to be exporter-related.

Like Exporter, IO​::Socket also defines an 'import' method. Since it
comes first in the DFS hierarchy (it's also the first for C3), it's the
one that's picked when the 'import' method is resolved for Foo.

You have to either put Exporter first or add an 'import' method to Foo
that redirects explicitely to Exporter​::import.

Vincent.

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2009

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

@p5pRT p5pRT closed this as completed Sep 28, 2009
@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2009

bitcard@profvince.com - Status changed from 'open' to 'rejected'

@p5pRT
Copy link
Author

p5pRT commented Sep 28, 2009

From @ikegami

iOn Mon, Sep 28, 2009 at 3​:42 PM, Vincent Pit <perl@​profvince.com> wrote​:

using base instead of parent does not change the problem, so it really
seems to be exporter-related.

Like Exporter, IO​::Socket also defines an 'import' method. Since it
comes first in the DFS hierarchy (it's also the first for C3), it's the
one that's picked when the 'import' method is resolved for Foo.

You have to either put Exporter first or add an 'import' method to Foo
that redirects explicitely to Exporter​::import.

Or use

use Exporter qw( import );

instead of inheriting from Exporter.

@p5pRT
Copy link
Author

p5pRT commented Sep 29, 2009

From @jquelin

On 09/09/28 21​:42 +0200, Vincent Pit wrote​:

using base instead of parent does not change the problem, so it really
seems to be exporter-related.

Like Exporter, IO​::Socket also defines an 'import' method. Since it
comes first in the DFS hierarchy (it's also the first for C3), it's the
one that's picked when the 'import' method is resolved for Foo.

i still think there's a bug lying there​: the behaviour did not happen
with perl 5.10.0, while it does now with 5.10.1
(this is because one of my modules now gets error from cpan testers
running 5.10.1, with the same code working without a flaw on cpan
testers 5.10.0

(note​: the original bug was spotted with class​::accessor​::fast, i
changed it to sthg else to see whether it would make the bug go away)

jérôme
--
jquelin@​gmail.com

@p5pRT
Copy link
Author

p5pRT commented Sep 29, 2009

From p5p@perl.wizbit.be

Citeren Jerome Quelin <jquelin@​gmail.com>​:

On 09/09/28 21​:42 +0200, Vincent Pit wrote​:

using base instead of parent does not change the problem, so it really
seems to be exporter-related.

Like Exporter, IO​::Socket also defines an 'import' method. Since it
comes first in the DFS hierarchy (it's also the first for C3), it's the
one that's picked when the 'import' method is resolved for Foo.

i still think there's a bug lying there​: the behaviour did not happen
with perl 5.10.0, while it does now with 5.10.1

It did happen on perl-5.10.0...

perl-5.10.0 after installing parent-0.223 from CPAN​:

$ /opt/perl/bin/perl5100 /tmp/rt-69450/test.pl
Global symbol "$FOO" requires explicit package name at
/tmp/rt-69450/test.pl line 6.
Execution of /tmp/rt-69450/test.pl aborted due to compilation errors.

What version of 'parent' are you using?
Perhaps parent changed?

Also​: this could never have worked if IO​::Socket is first in @​ISA...
Which is the case in your test script. IO​::Socket also defined an
import method on perl-5.10.0 meaning that one will get called first...

Best regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Sep 29, 2009

From @jquelin

On 09/09/29 09​:07 +0200, Bram wrote​:

i still think there's a bug lying there​: the behaviour did not happen
with perl 5.10.0, while it does now with 5.10.1

It did happen on perl-5.10.0...

perl-5.10.0 after installing parent-0.223 from CPAN​:

$ /opt/perl/bin/perl5100 /tmp/rt-69450/test.pl
Global symbol "$FOO" requires explicit package name at
/tmp/rt-69450/test.pl line 6.
Execution of /tmp/rt-69450/test.pl aborted due to compilation errors.

What version of 'parent' are you using?
Perhaps parent changed?

it happens both with base and parent.

look at cpan testers report​:
http​://matrix.cpantesters.org/?dist=POE-Component-Client-MPD+0.9.2
all 5.10.0 were working. only one fail for 5.10.1, which made me put
exporter at the first inheritance slot.

Also​: this could never have worked if IO​::Socket is first in @​ISA...
Which is the case in your test script. IO​::Socket also defined an
import method on perl-5.10.0 meaning that one will get called
first...

as i said, my is dual-inheriting from class​::accessor​::fast and
exporter, i changed to io​::socket to see if it was related to
class​::accessor.

jérôme
--
jquelin@​gmail.com

@p5pRT
Copy link
Author

p5pRT commented Sep 29, 2009

From p5p@perl.wizbit.be

Citeren Jerome Quelin <jquelin@​gmail.com>​:

On 09/09/29 09​:07 +0200, Bram wrote​:

i still think there's a bug lying there​: the behaviour did not happen
with perl 5.10.0, while it does now with 5.10.1

It did happen on perl-5.10.0...

perl-5.10.0 after installing parent-0.223 from CPAN​:

$ /opt/perl/bin/perl5100 /tmp/rt-69450/test.pl
Global symbol "$FOO" requires explicit package name at
/tmp/rt-69450/test.pl line 6.
Execution of /tmp/rt-69450/test.pl aborted due to compilation errors.

What version of 'parent' are you using?
Perhaps parent changed?

it happens both with base and parent.

...

Please show me a test case and the output of perl-5.10.0 and
perl-5.10.1. The only requirement is that the output in perl-5.10.0 is
different then the output in perl-5.10.1.

As said before​: the test case you supplied in the initial bug report
behaves the same on perl-5.10.0 as on perl-5.10.1. In addition​: how it
behaves is expected and has been explained.

look at cpan testers report​:
http​://matrix.cpantesters.org/?dist=POE-Component-Client-MPD+0.9.2
all 5.10.0 were working. only one fail for 5.10.1, which made me put
exporter at the first inheritance slot.

Also​: this could never have worked if IO​::Socket is first in @​ISA...
Which is the case in your test script. IO​::Socket also defined an
import method on perl-5.10.0 meaning that one will get called
first...

as i said,

As you said when?

Your initial bug report​:
  use parent qw{ IO​::Socket Exporter };
behaves differently then
  use parent qw{ Exporter IO​::Socket };

It does not mention any change in behaviour between perl-5.10.0 and
perl-5.10.1.
This change in behaviour is expected and was explained before.

Your second message talks about a change in behaviour between
perl-5.10.0 and perl-5.10.1. Where is the proof of that? Please submit
a test case + the output of perl-5.10.0 and perl-5.10.1 where the
output is not the same.

Your second message also mentions class​::accessor​::fast.

my is dual-inheriting from class​::accessor​::fast and
exporter, i changed to io​::socket to see if it was related to
class​::accessor.

So really, what is the issue here?
Or do you want me to trim it down from the fail report? (and 4 PASS reports?)
The fail report itself​:
- may or may not depend on to the OS it is being run on
- may or may not depend to the perl version it is running
- may or may not depend to the way perl was configured
- may or may not depend to the module itself
- may or may not depend on specific versions of other modules
- may or may not depend on something in the envirnoment of the tester
- ...

The bug report as you currently reported it​: works as intended +
expected + documented.

There could indeed be a regression between perl-5.10.0 and perl-5.10.1
which shows up in POE​::Component​::Client​::MPD but it isn't what you
reported thus far.

(And yes I could spend time on figuring out all the above stuff and
testing it on both perl-5.10.0 and perl-5.10.1 and attempting to
reproduce it and trim it down to something that is pure core but I'm
currently not really intrested in doing that.)

Best regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Sep 29, 2009

From @jquelin

On 09/09/29 18​:58 +0200, Bram wrote​:

Please show me a test case and the output of perl-5.10.0 and
perl-5.10.1. The only requirement is that the output in perl-5.10.0
is different then the output in perl-5.10.1.

here it is​:
$ cat foo
#!perl
use 5.010;
use strict;
use warnings;
use Foo;
say $FOO;
$ cat Foo.pm
package Foo;
use base qw{ Class​::Accessor​::Fast Exporter };
our @​EXPORT = qw{ $FOO };
our $FOO = 42;
1;

with custom perl 5.10.0
$ ./bin/perl -v

This is perl, v5.10.0 built for x86_64-linux-thread-multi

Copyright 1987-2007, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to
the
Internet, point your browser at http​://www.perl.org/, the Perl Home
Page.

$ ./bin/perl foo
42

now, here it is with perl 5.10.1
$ perl -v

This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to
the
Internet, point your browser at http​://www.perl.org/, the Perl Home
Page.

$ perl foo
Global symbol "$FOO" requires explicit package name at foo line 6.
Execution of foo aborted due to compilation errors.

some more information if you want - here are the module versions​:
perl 5.10.0​:
Class​::Accessor​::Fast​: 0.33
Exporter : 5.62
base : 2.13

perl 5.10.1​:
Class​::Accessor​::Fast​: 0.34
Exporter : 5.63
base : 2.14

so i tried to upgrade class​::accessor​::fast to 0.34 on perl 5.10.0 - and
*this* produces the same breakage in perl 5.10.0

so indeed, the problem comes from class​::accessor​::fast, that added some
import magic. however, given the input that i had, it looked like a
regression.

so, sorry for the noise...

regards,
jérôme
--
jquelin@​gmail.com

@p5pRT
Copy link
Author

p5pRT commented Sep 29, 2009

From p5p@perl.wizbit.be

Citeren Jerome Quelin <jquelin@​gmail.com>​:

On 09/09/29 18​:58 +0200, Bram wrote​:

Please show me a test case and the output of perl-5.10.0 and
perl-5.10.1. The only requirement is that the output in perl-5.10.0
is different then the output in perl-5.10.1.

here it is​:

Thanks for the feedback.

[...]

so indeed, the problem comes from class​::accessor​::fast, that added some
import magic. however, given the input that i had, it looked like a
regression.

Some general information​:

In reporting the bug you made two mistakes​:

1) modifying your test case (replacing Class​::Accessor​::Fast with
IO​::Socket) and only running it with perl-5.10.1. If you had ran it
with perl-5.10.0 you would have noticed that the output was the same.

2) misinterpreting the test reports​:
The test matrix shows 4 passes and 1 failure for perl-5.10.1.
This essentially means that the failure does not always happen but
depends on *something*. In your bug report you didn't
address/investigate what *something* is/was. If it really was a
regression from perl-5.10.0 to perl-5.10.1 then I would have expected
to see 5 failures.

so, sorry for the noise...

That's allright.. You are forgiven :)

Best regards,

Bram

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