Skip Menu |

This queue is for tickets about the Class-MethodMaker CPAN distribution.

Report information
The Basics
Id: 40822
Status: resolved
Priority: 0/
Queue: Class-MethodMaker

People
Owner: Nobody in particular
Requestors: lubo.rintel [...] gooddata.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 2.12
Fixed in: (no value)



Subject: Panic during global descruction
use threads; package foo; use Class::MethodMaker [ scalar => [ { -forward => [''] }, 'moo', ], ]; This chunk of code causes a Perl interpreter panic. Notice the '' string, which is not even nearly a good name for a method.
From: lubo.rintel [...] gooddata.com
Attaching a patch file, which adds some sensible diagnostics. (And yes, this kind of argument was really passed in a real world scenario :)
Improve diagnostics and avoid crash with bad arguments. Lubomir Rintel (Good Data) <lubo.rintel@gooddata.com> diff -urp Class-MethodMaker-2.12.orig/lib/Class/MethodMaker/Engine.pm Class-MethodMaker-2.12/lib/Class/MethodMaker/Engine.pm --- Class-MethodMaker-2.12.orig/lib/Class/MethodMaker/Engine.pm 2008-07-20 23:04:43.000000000 +0200 +++ Class-MethodMaker-2.12/lib/Class/MethodMaker/Engine.pm 2008-11-11 00:23:50.000000000 +0100 @@ -778,7 +778,8 @@ sub install_methods { *{$methname} = $code; # Generate a unique stash name for the sub. Use a preceding space # to avoid collisions with anything in the Perl space. - Class::MethodMaker::set_sub_name($code, $target, $name, "${target}::${name}"); + croak "Could not create stash name for '$name'" + unless Class::MethodMaker::set_sub_name($code, $target, $name, "${target}::${name}"); } } else { croak "What do you expect me to do with this?: $code\n"; diff -urp Class-MethodMaker-2.12.orig/MethodMaker.xs Class-MethodMaker-2.12/MethodMaker.xs --- Class-MethodMaker-2.12.orig/MethodMaker.xs 2008-03-24 21:46:41.000000000 +0100 +++ Class-MethodMaker-2.12/MethodMaker.xs 2008-11-11 00:25:06.000000000 +0100 @@ -4,8 +4,11 @@ MODULE = Class::MethodMaker PACKAGE = Class::MethodMaker -void +int set_sub_name(SV *sub, char *pname, char *subname, char *stashname) + INIT: + if (!SvTRUE(ST(1)) || !SvTRUE(ST(2)) || !SvTRUE(ST(3)) || !SvTRUE(ST(4))) + XSRETURN_UNDEF; CODE: CvGV((GV*)SvRV(sub)) = gv_fetchpv(stashname, TRUE, SVt_PV); GvSTASH(CvGV((GV*)SvRV(sub))) = gv_stashpv(pname, 1); @@ -15,3 +18,4 @@ set_sub_name(SV *sub, char *pname, char GvNAME(CvGV((GV*)SvRV(sub))) = savepv(subname); GvNAMELEN(CvGV((GV*)SvRV(sub))) = strlen(subname); #endif + RETVAL = 1;
Subject: Re: [rt.cpan.org #40822] Panic during global descruction
Date: Wed, 03 Dec 2008 02:34:11 +0100
To: bug-Class-MethodMaker [...] rt.cpan.org
From: Steffen Schwigon <ss5 [...] renormalist.net>
"Lubomir Rintel via RT" <bug-Class-MethodMaker@rt.cpan.org> writes: Show quoted text
> Queue: Class-MethodMaker > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=40822 > > > Attaching a patch file, which adds some sensible diagnostics. (And yes, > this kind of argument was really passed in a real world scenario :) > Improve diagnostics and avoid crash with bad arguments. > > Lubomir Rintel (Good Data) <lubo.rintel@gooddata.com>
Thanks. I applied it and uploaded v2.13. I also took the opportunity to finally upload it to a more public git repository: http://github.com/renormalist/class-methodmaker/tree/master Kind regards, Steffen -- Steffen Schwigon <ss5@renormalist.net> Dresden Perl Mongers <http://dresden-pm.org/> German Perl-Workshop <http://www.perl-workshop.de/>
Resolved. Hopefully. -- Steffen Schwigon <ss5@renormalist.net> Dresden Perl Mongers <http://dresden-pm.org/> Deutscher Perl-Workshop <http://www.perl-workshop.de/>