Skip Menu |

This queue is for tickets about the Convert-BER CPAN distribution.

Report information
The Basics
Id: 78587
Status: open
Priority: 0/
Queue: Convert-BER

Owner: Nobody in particular
Requestors: asjo [...]

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


Subject: encode() clobbers $@
Download (untitled) / with headers
text/plain 249b
When Convert::BER->encode() is called from a DESTROY method inside an eval { }, $@ is overwritten. I have encountered this with DBD::JDBC (0.70) - please see the attached minimal test case, and attached patch that fixes the problem for me. Thanks!
Subject: convert_ber_eval_clobber_fix.patch
--- 2012-07-26 16:33:01.934316033 +0200 +++ 2012-07-26 16:34:12.074124931 +0200 @@ -662,6 +662,7 @@ sub encode { my $ber = shift; local($SIG{'__DIE__'}); + local($@); $ber->[ Convert::BER::_INDEX() ] = [];
#!/usr/bin/perl use strict; use warnings; use Test::More; eval { my $some_thing=Some::Thing->new; die "CAUGHT\n"; }; my $error=$@; isnt($error, '', '$@ is not empty'); is($error, "CAUGHT\n", '$@ is CAUGHT'); done_testing; package Some::Thing; use Convert::BER; sub new { my ($class)=@_; return bless {}, $class; } sub DESTROY { my $ber=Convert::BER->new; $ber->encode(INTEGER=>1); # This clobbers $@ }
Subject: Re: [ #78587] encode() clobbers $@
Date: Thu, 26 Jul 2012 10:02:41 -0500
To: bug-Convert-BER [...]
From: Graham Barr <gbarr [...]>
Download (untitled) / with headers
text/plain 126b
I do not see this as a problem specific to Convert::BER *any* code which calls eval during DESTROY will clobber $@ Graham.
From: asjo [...]
Download (untitled) / with headers
text/plain 957b
On Thu Jul 26 11:03:03 2012, wrote: Show quoted text
> I do not see this as a problem specific to Convert::BER
Show quoted text
> *any* code which calls eval during DESTROY will clobber $@
Yeah, you're right - I just happened to encounter this when inside an eval a DBD::JDBC object was created and destroyed, and its DESTROY method called Convert::BER (while closing connections), which then called eval - which I guess was a surprise to the DBD::JDBC author. I took the handling of $SIG{__DIE__} in encode() as an indicator of Convert::BER "trying to be nice" to callers, but I readily admit that I am no expert. Maybe the correct fix is for DBD::JDBC's DESTROY to local'ize $@ instead? The code in question is disconnect()[1] which calls _send_request()[2] which then calls Convert::BER::encode(). Best regards, Adam [1] [2]

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to