On 2/26/15 12:26 AM, Octavian Rasnita wrote:
> Hello,
>
> I have the following test code. Here Moose and Moo are not useful so can
> be commented, but in production code they are needed.
>
> use forks;
> use Moose;
> use Moo;
>
> $SIG{__DIE__} = sub {
> print "thread died: @_\n" if @_;
> exit;
> };
>
> my $thread = threads->create( sub { print "Thread running\n"; } );
> $thread->join;
>
> If it is ran with:
> perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux
> Moose 2.0801
> Moo 1.000008
> forks 0.36
>
> then it gives the following error:
>
> thread died: Use of uninitialized value $name in hash element at
> /home/teddy/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2/Moo/HandleMoose.pm
> line 52.
>
> If either "use Moose;" or "use Moo;" are commented, the program works
> fine and prints "Thread running", so either Moose or Moo have a fatal
> effect here.
>
> If the code above is ran with:
> perl, v5.10.1 (*) built for x86_64-linux-thread-multi
> Moose 2.1403
> Moo 1.007
> forks 0.36
>
> then it gives another error:
>
> thread died: Can't use string ("Moo::HandleMoose::FakeMetaClass") as a
> HASH ref while "strict refs" in use at
> /usr/local/share/perl5/Moo/HandleMoose/FakeMetaClass.pm line 13.
>
> If either "use Moose;" or "use Moo;" are commented, the code also works
> fine.
>
> Do you have any idea what could be the problem?
>
> Thanks.
>
> --Octavian
>
This is somewhat a bug in Moo, and also possibly a bug in forks.
forks scans through every package checking for CLONE_SKIP subs. It uses
->can to do this. This mostly matches the behavior of threads, except
they don't use ->can to check for this. So this is a slight difference
in behavior that forks should maybe fix.
Moo contains a package that doesn't work when ->can is used as a class
method. This is the direct cause of the error, and I should have that
fixed soon.