Skip Menu |

This queue is for tickets about the Object-Trampoline CPAN distribution.

Report information
The Basics
Id: 48094
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: Object-Trampoline

People
Owner: LEMBARK [...] cpan.org
Requestors: devnull-bitcard [...] punchit.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.25
Fixed in: (no value)



Hey Steve! Just bumped into 2 small issues in 3 locations using 1.25. Diff attached. - Does not properly check the case where $class is undefined, but @argz has values - Does not report any problems encountered by eval { use $class } Best, Rob
Subject: Trampoline.pm.diff
--- Trampoline.pm.orig 2009-07-22 15:39:59.000000000 -0400 +++ Trampoline.pm 2009-07-22 15:40:14.000000000 -0400 @@ -52,8 +52,10 @@ shift; - my ( $class, @argz ) = @_ - or croak "Bogus Object::Trampoline: missing destination class"; + my ( $class, @argz ) = @_; + + croak "Bogus Object::Trampoline: missing destination class" + unless (defined $class); my $const = ( split /::/, $AUTOLOAD )[ -1 ]; @@ -88,8 +90,10 @@ # grab the destination class and its arguments off the stack. # the constructor name is whatever is being autoloaded. - my ( $class, @argz ) = @_ - or croak "Bogus Object::Trampoline: missing destination class"; + my ( $class, @argz ) = @_; + + croak "Bogus Object::Trampoline: missing destination class" + unless (defined $class); my $const = ( split /::/, $AUTOLOAD )[ -1 ]; @@ -104,6 +108,9 @@ use $class; }; + croak "Failed to eval class: $@" + if ($@); + $class->$const( @argz ) };
Subject: Re: [rt.cpan.org #48094]
Date: Wed, 22 Jul 2009 20:05:22 -0400
To: bug-Object-Trampoline [...] rt.cpan.org
From: Steven Lembark <lembark [...] wrkhors.com>
On Wed, 22 Jul 2009 16:00:49 -0400 "devbike via RT" <bug-Object-Trampoline@rt.cpan.org> wrote: Show quoted text
> Wed Jul 22 16:00:48 2009: Request 48094 was acted upon. > Transaction: Ticket created by devbike > Queue: Object-Trampoline > Subject: (No subject given) > Broken in: 1.25 > Severity: Normal > Owner: Nobody > Requestors: devnull-bitcard@punchit.net > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=48094 > > > > Hey Steve! > > Just bumped into 2 small issues in 3 locations using 1.25. Diff > attached. > > - Does not properly check the case where $class is undefined, but > @argz has values
Have not seen that one before: where does it show up in your code (i.e., why pass an explicit undef for the first argument)? Show quoted text
> - Does not report any problems encountered by eval { use $class }
oops. -- Steven Lembark 85-09 90th St. Workhorse Computing Woodhaven, NY, 11421 lembark@wrkhors.com +1 888 359 3508
On Wed Jul 22 20:05:34 2009, lembark@wrkhors.com wrote: Show quoted text
> On Wed, 22 Jul 2009 16:00:49 -0400 > "devbike via RT" <bug-Object-Trampoline@rt.cpan.org> wrote: > > Have not seen that one before: where does it > show up in your code (i.e., why pass an explicit > undef for the first argument)? >
It was actually a bug in my code, but the error returned took a little time to track down. Consider this case: ######## package MyPackage; my $class = get_class(); my @artgz = get_argz(); my $obj = Object:Trampoline::Use->new($class, @argz); # ....sometime later, in a module far, far away... my $obj = get_obj(); $obj->frobnicate(); ######## At the frobnicate() call, the Bounce object calls $class->new(@argz)...but in a case where incomplete error checking is done and get_class() fails, $class is undef. This causes everything to fall over with a "Can't call method "new" on an undefined value at /Library/Perl/5.8.8/Object/Trampoline.pm line 107." As opposed to the submitted patch which says: Bogus Object::Trampoline: missing destination class at MyPackage.pm line 50 This points the direction of study in the caller's code rather than hunting for something wrong with Trampoline itself. The error points to the actual (user) code that has the undef, rather than giving a line in the O:T module at a point in runtime where frobnicate is executing. The issue is still 100% with the calling code, but the error is prettier. :)
Subject: Fixed
I've added sanity checks for false class and a regex for legit package name; also check the result of eval-ing the use. Uses "blessed" rather than "ref" to check the construction result also. ./t/03.t checks for rejecting '' and undef classes, a few known-bogus ones, and a known-failing class.