Skip Menu |

This queue is for tickets about the Moops CPAN distribution.

Report information
The Basics
Id: 99389
Status: resolved
Priority: 0/
Queue: Moops

People
Owner: perl [...] toby.ink
Requestors: AMON [...] cpan.org
SAUBER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.033
Fixed in: (no value)



Subject: Using nonexistent role gobbles up all memory
If a Moops class uses a role that does not exist, then for some reason the application will run out of memory and crash. Minimal example to reproduce: use Moops; class Foo with DoesNotExist; Tested with Moops 0.033 on perl 5.18.2 and perl 5.20.1
Yowzers! That's a nasty one. This also gobbles up memory: use Moops; class Foo with DoesNotExist { 1 }; So it's not related to empty class definitions. And this fails nicely without gobbling memory: use Moops; class Foo { with qw(DoesNotExist) }; Overall, it seems likely to be caused by applying non-existent roles to the class within a Scope::Guard guard block. Perhaps something odd happens if an exception is thrown in the guard block?
Subject: Missing required method causes segmentation fault
Minimal example for how methods required by role will cause segmentation fault when missing: ~$ cat C.pm use Moops; role R { requires 'm'; } class C with R { } ~$ perl -MC -e0 Segmentation fault (core dumped) ~$ perl -c C.pm Segmentation fault (core dumped) ~$ perl --version This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi [...] ~$
This seems to be the same thing as RT#99389.
Replacing Scope::Guard with Guard.pm fixes things, but I'm not sure I want to rely on Guard.pm which is mlehmannware.
# Viable replacement for Scope::Guard/Guard.pm # from BenGoldberg on IRC... use v5.14; BEGIN { package Magic::Guard; use Variable::Magic qw(wizard cast); use constant CALL_ON_FREE => wizard data => sub { $_[1] }, free => sub { $_[1]() }; sub guard(&) { my $magic; cast $magic, CALL_ON_FREE, $_[0]; \$magic } sub import { no strict 'refs'; *{caller.'::guard'} = \&guard } }; no thanks qw(Magic::Guard); use Magic::Guard; do { my $x = guard { say "in guard"; die "here"; }; say "hello"; };
Resolved in Moops 0.034.