Dancer2 icon indicating copy to clipboard operation
Dancer2 copied to clipboard

Deep recursion on anonymous subroutine at ../5.22.0/Dancer2/Core/App.pm line 1177.

Open szabgab opened this issue 5 years ago • 5 comments

It is the 'eval { $EVAL_SHIM->($hook,@_); 1; }' line in the 'compile_hooks' function in version 0.206000.

I still could not figure out what causes it and if the problem is in my code or in Dancer2, I just wanted to record the issue and will update it when I understand it better. (I see this when I send out e-mails using the bin/sendmail.pl script in https://github.com/szabgab/Perl-Maven )

szabgab avatar Sep 08 '18 07:09 szabgab

That sendmail script doesn't seem to use any Dancer2 keywords. I'm wondering if the following resolves the deep recursion:

  • removing the use Dancer2; in line 11, and
  • replacing line 56 with my $dancer = Perl::Maven->psgi_app;

The use Dancer2; in the script is creating a second dancer app (probably in the main namespace); I'm hypothesising that is responsible for the deep recursion in some way. It'd be nice to know how the above suggestion behaves before going digging further..

veryrusty avatar Sep 08 '18 10:09 veryrusty

Now I paid more attention and the warning starts to appear after sending out the email to 98 people so it is somehow created by my repeated calls.

szabgab avatar Sep 09 '18 08:09 szabgab

using -d:Confess I got the following stack trace:

Deep recursion on anonymous subroutine at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1177.
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:37](CODE(0x5962788), Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1177
        eval {...} called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1178
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1184](Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 36
 
       ....
         eval {...} called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1178
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1184](Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 36
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:37](CODE(0x611f950), Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1177
        eval {...} called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1178
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1184](Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/Role/Hookable.pm line 115
        Dancer2::Core::Role::Hookable::execute_hook(Dancer2::Core::App=HASH(0x3295aa0), "core.app.before_request", Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 676
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:677](CODE(0x2f54c88), Dancer2::Core::App=HASH(0x3295aa0), "core.app.before_request", Dancer2::Core::App=HASH(0x3295aa0)) called at (eval 185)[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Class/Method/Modifiers.pm:93] line 1
        Dancer2::Core::App::__ANON__[(eval 185)[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Class/Method/Modifiers.pm:93]:1](Dancer2::Core::App=HASH(0x3295aa0), "core.app.before_request", Dancer2::Core::App=HASH(0x3295aa0)) called at (eval 187)[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Class/Method/Modifiers.pm:152] line 2
        Dancer2::Core::App::execute_hook(Dancer2::Core::App=HASH(0x3295aa0), "core.app.before_request", Dancer2::Core::App=HASH(0x3295aa0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1578
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1579]() called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 36
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:37](CODE(0x62bfab0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1579
        eval {...} called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1581
        Dancer2::Core::App::_dispatch_route(Dancer2::Core::App=HASH(0x3295aa0), Dancer2::Core::Route=HASH(0x596e420)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1473
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1474](CODE(0x612e2f0)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Return/MultiLevel.pm line 36
        Return::MultiLevel::with_return(CODE(0x6092728)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1474
        Dancer2::Core::App::dispatch(Dancer2::Core::App=HASH(0x3295aa0), HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1386
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1386]() called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 36
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:37](CODE(0x612da68)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1386
        eval {...} called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm line 1388
        Dancer2::Core::App::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm:1398](HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Middleware/FixMissingBodyInRedirect.pm line 50
        Plack::Middleware::FixMissingBodyInRedirect::call(Plack::Middleware::FixMissingBodyInRedirect=HASH(0x611fba8), HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Component.pm line 50
        Plack::Component::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Component.pm:50](HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Middleware/Conditional.pm line 16
        Plack::Middleware::Conditional::call(Plack::Middleware::Conditional=HASH(0x62bbb98), HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Component.pm line 50
        Plack::Component::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Component.pm:50](HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Middleware/Head.pm line 10
        Plack::Middleware::Head::call(Plack::Middleware::Head=HASH(0x62bf840), HASH(0x60c0088)) called at /home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Component.pm line 50
        Plack::Component::__ANON__[/home/gabor/perl-5.22.0/lib/site_perl/5.22.0/Plack/Component.pm:50](HASH(0x60c0088)) called at bin/sendmail.pl line 69
        main::build_content("https://perlmaven.com/mail/20180909_pro", "") called at bin/sendmail.pl line 135
        main::send_messages(HASH(0x3147c90), HASH(0x53e2830), HASH(0x15205e0)) called at bin/sendmail.pl line 48
        main::main() called at bin/sendmail.pl line 24

szabgab avatar Sep 09 '18 08:09 szabgab

Thanks @szabgab. I can see what's going on now; repeatedly calling MyApp->psgi_app is recompiling the hooks, causing "chains" of $EVAL_SHIM->($EVAL_SHIM->($EVAL_SHIM->(...)))

We should catch and log and/or warn in the core. Until that's implemented, you could modify your code to only create the app once. state $dancer = Perl::Maven->psgi_app; should suffice.

veryrusty avatar Sep 10 '18 11:09 veryrusty

Changing the code so that I'll call Perl::Maven->psgi_app; only once fixed the issue. https://github.com/szabgab/Perl-Maven/commit/cec4dbe636e1282a6d7f0665635988cf808a4eb5

BTW FYI this whole warning thing appeared only in a recent upgrade.

Feel free to close this issue or keep it open as you wish!

In any case thank you for your help!

szabgab avatar Sep 13 '18 18:09 szabgab