Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 104854
Status: rejected
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: dmuey [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 1.004002
  • 1.007000
Fixed in: (no value)



Subject: Moo’s BEGIN/INIT codepath is not perlcc safe (“Not a CODE reference.”)
Howdy, [Problem] use Moo::Based::Class; causes perlcc'd code to exit early (w/ 0 oddly enough) with “Not a CODE reference.”. [A little more detail] The behavior is like something (Sub::Defer related?) is happening at INIT that is depending on something having happened at BEGIN. Except with compiled code BEGIN is already done and is not executed again. To really grok what is happening I suggest adding in 'use diagnostics;' and debuging output along the way. I hope to narrow it down further time permitting but for now I wanted to get some other eyes on it too :) [In Action] The modules in the commands below are detailed under “[The files in the examples]” at the end. Here is what can be done to [see the problem/deonstrate a work around to this limitation/test any fixes]. "a" and "b" work by forcing the entire Moo class mojo to happen after BEGIN, which isn't ideal obviously but it helps us see the problem and se something that makes it go away. a. When use()d in main scope of a program you must require the Moo based class: # perl -e 'use tmp::MyMoo;print Moo->VERSION. "\n";' 1.007 # perlcc -e 'use tmp::MyMoo;print Moo->VERSION. "\n";' -o tmp/moo_use_direct /usr/local/cpanel/3rdparty/perl/514/bin/perlcc: Unexpected compiler output Internal warning: IV !IOK Sub::Defer::DEFERRED{CODE(0x9adcbd4)}[3] sv_list[3928] 0x2 Internal warning: IV !IOK Sub::Defer::DEFERRED{CODE(0x9adc7ec)} sv_list[3930] 0x2 Internal warning: IV !IOK Sub::Quote::QUOTED{CODE(0x9adcbd4)}[4] sv_list[5002] 0x2 tmp/moo_use_direct.c:26108: warning: integer constant is too large for ‘unsigned long’ type # tmp/moo_use_direct 1.007 Not a CODE reference. END failed--call queue aborted. # perl -e 'require tmp::MyMoo;print Moo->VERSION. "\n";' 1.007 # perlcc -e 'require tmp::MyMoo;print Moo->VERSION. "\n";' -o tmp/moo_require_direct # tmp/moo_require_direct 1.007 # b. When use()d by a module you must do so via require *and* also wrap the require in an INIT block: # perl -e 'use tmp::XYZ tmp::MyMoo;print Moo->VERSION. "\n";' 1.007 # perlcc -e 'use tmp::XYZ tmp::MyMoo;print Moo->VERSION. "\n";' -o tmp/moo_use_indrectly_via_use /usr/local/cpanel/3rdparty/perl/514/bin/perlcc: Unexpected compiler output Internal warning: IV !IOK Sub::Defer::DEFERRED{CODE(0xa1ec528)} sv_list[3925] 0x2 Internal warning: IV !IOK Sub::Defer::DEFERRED{CODE(0xa1ec910)}[3] sv_list[3981] 0x2 Internal warning: IV !IOK Sub::Quote::QUOTED{CODE(0xa1ec528)}[4] sv_list[5002] 0x2 tmp/moo_use_indrectly_via_use.c:26110: warning: integer constant is too large for ‘unsigned long’ type # tmp/moo_use_indrectly_via_use 1.007 Not a CODE reference. END failed--call queue aborted. # vim tmp/XYZ.pm # change use tmp::MyMoo; to require tmp::MyMoo; # perl -e 'use tmp::XYZ tmp::MyMoo;print Moo->VERSION. "\n";' 1.007 # perlcc -e 'use tmp::XYZ tmp::MyMoo;print Moo->VERSION. "\n";' -o tmp/moo_require_indirectly_via_use /usr/local/cpanel/3rdparty/perl/514/bin/perlcc: Unexpected compiler output Internal warning: IV !IOK Sub::Defer::DEFERRED{CODE(0x9550c90)}[3] sv_list[4065] 0x2 Internal warning: IV !IOK Sub::Defer::DEFERRED{CODE(0x95508a8)} sv_list[4137] 0x2 Internal warning: IV !IOK Sub::Quote::QUOTED{CODE(0x9550c90)}[4] sv_list[5002] 0x2 tmp/moo_require_indirectly_via_use.c:26110: warning: integer constant is too large for ‘unsigned long’ type # tmp/moo_require_indirectly_via_use 1.007 Not a CODE reference. END failed--call queue aborted. # vim tmp/XYZ.pm # change require tmp::MyMoo; to INIT {require tmp::MyMoo;} # perl -e 'use tmp::XYZ tmp::MyMoo;print Moo->VERSION. "\n";' 1.007 # perlcc -e 'use tmp::XYZ tmp::MyMoo;print Moo->VERSION. "\n";' -o tmp/moo_require_init_indirectly_via_use # tmp/moo_require_init_indirectly_via_use 1.007 # [The files in the examples] # cat tmp/XYZ.pm package tmp::XYZ; use strict; use warnings; use tmp::MyMoo; 1; # cat tmp/MyMoo.pm package tmp::MyMoo; use Moo; # does strict and warnings has foo => ("is" => "rw"); 1; #
It might make more sense if I could move: “To really grok what is happening I suggest adding in 'use diagnostics;' and debuging output along the way.” to after : “The modules in the commands below are detailed under “[The files in the examples]” at the end.” :)
I'm not having much luck reproducing this. It always seems to run without issue for me. Also note that Moo doesn't use INIT anywhere.
On Tue Jun 09 18:22:20 2015, haarg wrote: Show quoted text
> I'm not having much luck reproducing this. It always seems to run > without issue for me.
What does perlcc --verison output for you? Mine is: perlcc 2.18, B-C-1.47_03 built for /usr/local/cpanel/3rdparty/perl/514/bin/perl i386-linux-64int Show quoted text
> Also note that Moo doesn't use INIT anywhere.
I only mentioned INIT as a description of how the “behavior is like something … is happening at INIT”. It could really be any stage after BEGIN.
On Tue Jun 09 18:32:16 2015, DMUEY wrote: Show quoted text
> On Tue Jun 09 18:22:20 2015, haarg wrote:
> > I'm not having much luck reproducing this. It always seems to run > > without issue for me.
> > What does perlcc --verison output for you? > > Mine is: > > perlcc 2.18, B-C-1.47_03 built for > /usr/local/cpanel/3rdparty/perl/514/bin/perl i386-linux-64int
$ perlcc --version Use of uninitialized value $B::C::REVISION in concatenation (.) or string at /Users/gknop/perl5/perlbrew/perls/perl-5.14.4/bin/perlcc line 860. perlcc 2.2, B-C-1.52 built for /Users/gknop/perl5/perlbrew/perls/perl-5.14.4/bin/perl darwin-2level
This should not be a Moo ticket I think, rather at B::C. I can reproduce this on one of my perl5.14.4 versions, not on the others. -- Reini Urban
On Tue Jun 09 18:44:19 2015, RURBAN wrote: Show quoted text
> This should not be a Moo ticket I think, rather at B::C.
Probably. If there's something we are doing in Moo that could be improved to help perlcc work, we'd probably be up for it. But I'm not able to properly debug this so even if we want to change something, I can't help much in tracking it down. As a side note, if you are compiling Moo code, I suspect you'd want to include a BEGIN { Sub::Defer::undefer_all() }, so that Moo would do all of its code gen upfront.
On Tue Jun 09 18:44:19 2015, RURBAN wrote: Show quoted text
> This should not be a Moo ticket I think, rather at B::C. > I can reproduce this on one of my perl5.14.4 versions, not on the others.
Confirmed. The missing function here is XSLoader::load, and is caused by a bad perl installation (in my case), or the compiler not seeing that XSLoader is needed. Please reject -- Reini Urban
Show quoted text
> As a side note, if you are compiling Moo code, I suspect you'd want to > include a BEGIN { Sub::Defer::undefer_all() }, so that Moo would do > all of its code gen upfront.
cool, thanks!
Show quoted text
> As a side note, if you are compiling Moo code, I suspect you'd want to > include a BEGIN { Sub::Defer::undefer_all() }, so that Moo would do > all of its code gen upfront.
cool, thanks!
On Tue Jun 09 19:52:39 2015, RURBAN wrote: Show quoted text
> On Tue Jun 09 18:44:19 2015, RURBAN wrote:
> > This should not be a Moo ticket I think, rather at B::C. > > I can reproduce this on one of my perl5.14.4 versions, not on the > > others.
> > Confirmed. The missing function here is XSLoader::load, and is caused > by a bad perl installation (in my case), or the compiler not seeing > that XSLoader is needed. > Please reject
thanks Reini, I reckon we need an initernal ticket then :)
Rejecting, as this is a B::C issue, not a Moo issue.
FYI, https://github.com/rurban/perl-compiler/issues/201 is the B::C issue for this, thanks!