Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug in Moose, Moo or forks?

1 view
Skip to first unread message

Octavian Rasnita

unread,
Feb 26, 2015, 12:45:02 AM2/26/15
to mo...@perl.org
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

Graham Knop

unread,
Feb 27, 2015, 11:15:05 AM2/27/15
to mo...@perl.org
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.

Graham Knop

unread,
Feb 27, 2015, 12:45:01 PM2/27/15
to mo...@perl.org
On 2/27/15 11:08 AM, Graham Knop wrote:
> On 2/26/15 12:26 AM, Octavian Rasnita wrote:
>> Hello,
> 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.
>

I've filed https://rt.cpan.org/Ticket/Display.html?id=102407 for issue
on the forks side. Moo has been fixed in git and a new release should
be out soon.
0 new messages