p5-Mouse icon indicating copy to clipboard operation
p5-Mouse copied to clipboard

No $self in sub() with lazy => 1 and mod_perl with Apache MPM worker

Open coudot opened this issue 10 years ago • 7 comments

We have a strange bug in LemonLDAP::NG: https://jira.ow2.org/browse/LEMONLDAP-723

It seems that Mouse, with Perl v5.10.1, running inside Apache mod_perl with the MPM worker cannot run this kind of code:

has 'registerUrl' => (
    is      => 'rw',
    isa     => 'Str',
    default => sub {
        my $self = shift;
        return $self->portal . "register.pl";
    },
    lazy          => 1,
    documentation => 'URL of register page',
);

The error we see in Apache is:

[Tue Jul 15 14:12:17 2014] [error] Exception caught: Can't call method "portal" on an undefined value at /usr/share/perl5/vendor_perl/Lemonldap/NG/Common/Conf/Attributes.pm line 951.\n

I tried to use Mouse 2.3.0, but same error.

I can't reprodure with a more recent version of Perl (v5.18.2), or with MPM prefork.

Clément.

coudot avatar Jul 15 '14 12:07 coudot

Hmm, I think it is intended. How about Moose?

gfx avatar Jul 15 '14 13:07 gfx

We don't use Moose to have a lighter memory use, but I can maybe give a try.

Why do you say it's intended? Seems to work well on recent Perl.

coudot avatar Jul 15 '14 13:07 coudot

Oh, I'm sorry I didn't see what you said, "I can't reprodure with a more recent version of Perl (v5.18.2)".

It looks a bug and should be fixed.

gfx avatar Jul 15 '14 13:07 gfx

@coudot Can this bug reproduce without Apachie mod_perl ?

There are some tests which uses lazy and subroutine argument of default attribute, for example t/200_examples/0071_Child_Parent_attr_inherit_imm.t. However such tests are passed on Perl 5.10.1.

syohex avatar Jul 16 '14 02:07 syohex

Sadly, the bug occurs only in mod_perl, with MPM worker, with quite old Perl version (5.10). It works well on the same system with MPM prefork.

I can reproduce the bug on CentOS 6 with standard packages.

coudot avatar Jul 16 '14 07:07 coudot

Hmmm, MPM worker uses multiple threads iirc, I wonder if this related to the issues here? https://github.com/gfx/p5-Mouse/issues/29

pwr22 avatar Aug 02 '15 01:08 pwr22

Thread issue was fixed at #50. Please check latest version again

syohex avatar Aug 02 '15 08:08 syohex