Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 39904
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: MARKSTOS [...] cpan.org
Requestors: rhomel.chinsio [...] gmail.com
Cc:
AdminCc:

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



Subject: CGI::Carp fatalsToBrowser does not catch stringifiable objects
When an exception module like Exception::Class 1.24 is used that uses die and exception objects to throw exceptions, uncaught exceptions (effectively die calls with object references instead of strings) are not intercepted by CGI::Carp. After reviewing the source to both Exception::Class and CGI::Carp this is due to CGI::Carp's unwillingness to touch objects it does not understand (because it does not have a reliable way to stringify them?). Well Exception::Class overloads the "" operator to enable stringification if the caller expects strings. So in order to get CGI::Carp to intercept uncaught exceptions that are outside of an eval block, I had to add the following to CGI::Carp.pm 1.30_01: 318a319 Show quoted text
> use overload;
443a445,446 Show quoted text
> $arg = "$arg" if overload::Method($arg, '""'); # Exception::Class
stringification compatibility Show quoted text
>
All this does is stringify an object if it has overloaded the "" operator. This allows CGI::Carp to intercept and reformat uncaught exceptions thrown from Exception modules implemented similar to Exception::Class. Also it is important that this line is placed after the ineval check block because it is likely exceptions should not be intercepted when they are thrown inside of an eval block. I believe eval is the only mechnism used to effectively catch exceptions.
I'd like to see this fixed, too. Can anyone enlighten me why CGI::Carp calls realdie when it encounters a reference? Shouldn't this check be simply removed?
I'm working on a patch and tests. Something should be ready in a couple of days.
On Thu Aug 27 19:12:11 2009, YANICK wrote: Show quoted text
> I'm working on a patch and tests. Something should be ready in a couple > of days.
Fix available at http://github.com/yanick/CGI.pm/commits/rt-39904
Thanks, this has been patched in my github repo now.
Subject: Thanks, released
The patch for this ticket has now been released in CGI.pm 3.47, and this ticket is considered resolved. Thanks again for you help to improve CGI.pm! Mark
The patch for this in 3.47 had to be reverted in 3.48. However, we have a new proposed fix that we think addresses your concern, without introducing the regression that caused us to role it back in 3.48. Could test the following copy of CGI::Carp and see if it works for you? http://github.com/markstos/CGI.pm/raw/master/lib/CGI/Carp.pm Mark
From: rhomel.chinsio [...] gmail.com
I tried the patched Carp.pm against 3.48. It seems to work as expected for my needs. On Sat Oct 03 20:13:04 2009, MARKSTOS wrote: Show quoted text
> The patch for this in 3.47 had to be reverted in 3.48. However, we have a > new proposed fix that we think addresses your concern, without > introducing the regression that caused us to role it back in 3.48. > > Could test the following copy of CGI::Carp and see if it works for you? > > http://github.com/markstos/CGI.pm/raw/master/lib/CGI/Carp.pm > > Mark
This fix was released in 3.49.