Skip Menu |
 

This queue is for tickets about the Mojolicious-Plugin-Util-RandomString CPAN distribution.

Report information
The Basics
Id: 125981
Status: patched
Priority: 0/
Queue: Mojolicious-Plugin-Util-RandomString

People
Owner: AKRON [...] cpan.org
Requestors: ether [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.07



Subject: memory leak with $mojo in closure
Download (untitled) / with headers
text/plain 634b
I added Test::Memory::Cycle to a test suite to check for memory leaks on my app object, and it found this leak in your plugin: # Cycle #1 # Test::MyApp A->{ua} => Mojo::UserAgent B # Mojo::UserAgent B->{server} => Mojo::UserAgent::Server C # Mojo::UserAgent::Server C->{app} => MyApp D # MyApp D->{renderer} => Mojolicious::Renderer E # Mojolicious::Renderer E->{helpers} => %F # %F->{random_string} => &G # closure &G, $mojo => $H # $H => MyApp D It looks like $mojo should be weakened when it is closed over in the random_string sub. (See Scalar::Util::weaken.)
Download (untitled) / with headers
text/plain 769b
Am Mi 01. Aug 2018, 17:44:29, ETHER schrieb: Show quoted text
> I added Test::Memory::Cycle to a test suite to check for memory leaks > on my app object, and it found this leak in your plugin: > > # Cycle #1 > # Test::MyApp A->{ua} => Mojo::UserAgent B > # Mojo::UserAgent B->{server} => Mojo::UserAgent::Server C > # Mojo::UserAgent::Server C->{app} => MyApp D > # MyApp D->{renderer} => Mojolicious::Renderer E > # Mojolicious::Renderer E->{helpers} => %F > # %F->{random_string} => &G > # closure &G, $mojo => $H > # $H => MyApp D > > It looks like $mojo should be weakened when it is closed over in the > random_string sub. (See Scalar::Util::weaken.)
Thank you for finding this bug and even hinting for a solution! I will try to fix it next week.
Download (untitled) / with headers
text/plain 384b
My solution wasn't that great. :) Instead of weakening the $mojo object that was passed to you in the 'register' call, just get it at runtime from the arguments passed to the helper sub (the one you're shifting off and not using right now). I think it's a $c (controller), so instead of $mojo, just use $c->app. e.g. $c->app->log->warn(qq!RandomString generator "$gen" is unknown!);
Download (untitled) / with headers
text/plain 658b
Am Mi 08. Aug 2018, 11:21:56, ETHER schrieb: Show quoted text
> My solution wasn't that great. :) Instead of weakening the $mojo > object that was passed to you in the 'register' call, just get it at > runtime from the arguments passed to the helper sub (the one you're > shifting off and not using right now). I think it's a $c (controller), > so instead of $mojo, just use $c->app. > > e.g. $c->app->log->warn(qq!RandomString generator "$gen" is unknown!);
Today I was able to check, test and hopefully fix the issue in the 0.07 release. Thank you very, very much for the bug report and introducing me to Test::Memory::Cycle! I wasn't aware of this extremely useful tool!
Download (untitled) / with headers
text/plain 315b
On 2018-08-10 07:15:26, AKRON wrote: Show quoted text
> Today I was able to check, test and hopefully fix the issue in the > 0.07 release. Thank you very, very much for the bug report and > introducing me to Test::Memory::Cycle! I wasn't aware of this > extremely useful tool!
Awesome, thank you! And thanks for that other thing!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.