Skip Menu |
 

This queue is for tickets about the CGI-Session CPAN distribution.

Report information
The Basics
Id: 18183
Status: resolved
Priority: 0/
Queue: CGI-Session

People
Owner: Nobody in particular
Requestors: dcturner2000 [...] yahoo.co.uk
Cc:
AdminCc:

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

Attachments


Subject: DESTROY wipes out exception handling
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1142429761-14039-4"
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 495
Download (untitled) / with headers
text/plain 495b
If I initialise CGI::Session then die() with a message, the message gets lost which makes debugging rather frustrating. I am using the postgresql driver. The error seems to be that eval{} is used within the cleanup, which wipes out $@ if no error occurs. The attached patch provides the best description of the problem by offering a quick-and-dirty fix for my case. There probably is a much better way; perhaps use Error qw(:try)? Version CGI::Session 4.07, perl 5.8.6, Linux 2.6.10
Subject: exception-fix.patch
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1142429761-14039-3"
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Type: text/x-diff; name="exception-fix.patch"
Content-Disposition: inline; filename="exception-fix.patch"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: ascii
Content-Length: 798
Download exception-fix.patch
text/x-diff 798b
diff -U3 -r ./Session/Driver/postgresql.pm /usr/lib/perl5/site_perl/5.8.6/CGI/Session/Driver/postgresql.pm --- ./Session/Driver/postgresql.pm 2006-03-09 12:02:19.000000000 +0000 +++ /usr/lib/perl5/site_perl/5.8.6/CGI/Session/Driver/postgresql.pm 2006-03-15 13:24:11.560071302 +0000 @@ -63,14 +63,20 @@ sub __ex_and_ret { my ($dbh,$sql,$datastr,$sid,$type) = @_; + my $save_error = $@; eval { my $sth = $dbh->prepare($sql) or return 0; $sth->bind_param(1,$datastr,{ pg_type => $type }) or return 0; $sth->bind_param(2,$sid) or return 0; $sth->execute() or return 0; }; - return 0 if $@; - return 1; + if ($@) { + $@ = $save_error; + return 0; + } else { + $@ = $save_error; + return 1; + } } 1;
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-14039-1142429765-1738.18183-4-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: local policy)
References: <RT-Ticket-18183 [...] rt.cpan.org> <rt-3.5.HEAD-14039-1142429765-1738.18183-4-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id ECBE84D822F for <cpan-bug+cgi-session [...] diesel.bestpractical.com>; Wed, 15 Mar 2006 09:10:37 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 424BD4D822E for <bug-CGI-Session [...] rt.cpan.org>; Wed, 15 Mar 2006 09:10:37 -0500 (EST)
Received: (qmail 30813 invoked by alias); 15 Mar 2006 14:10:33 -0000
Received: from tanagra.summersault.com (HELO tanagra.summersault.com) (12.161.105.149) by la.mx.develooper.com (qpsmtpd/0.28) with SMTP; Wed, 15 Mar 2006 06:10:30 -0800
Received: (qmail 47656 invoked by uid 1002); 15 Mar 2006 14:10:22 -0000
Delivered-To: cpan-bug+cgi-session [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #18183] DESTROY wipes out exception handling
User-Agent: Mutt/1.5.6i
Return-Path: <mark [...] summersault.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+cgi-session [...] diesel.bestpractical.com
Date: Wed, 15 Mar 2006 09:10:22 -0500
Message-Id: <20060315141022.GK98976 [...] summersault.com>
To: Guest via RT <bug-CGI-Session [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-14039-1142431843-787.18183-0-0 [...] rt.cpan.org>
Content-Length: 773
Download (untitled) / with headers
text/plain 773b
On Wed, Mar 15, 2006 at 08:36:06AM -0500, Guest via RT wrote: Show quoted text
> > If I initialise CGI::Session then die() with a message, the message > gets lost which makes debugging rather frustrating. I am using the > postgresql driver. The error seems to be that eval{} is used within > the cleanup, which wipes out $@ if no error occurs. > > The attached patch provides the best description of the problem by > offering a quick-and-dirty fix for my case. There probably is a much > better way; perhaps use Error qw(:try)?
This patch looks reasonable to me. In terms of a "better way", on the cgi-session-users list, we are discussing alternatives to make the use of DESTORY optional, but having the "flush()" kinds of actions happen explicitly, or at other points. Mark


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.