develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #74538] destructor can squash main exception

Thread Next
From:
Father Chrysostomos via RT
Date:
January 7, 2012 00:50
Subject:
[perl #74538] destructor can squash main exception
Message ID:
rt-3.6.HEAD-14510-1325926209-270.74538-15-0@perl.org
On Tue Apr 20 12:35:47 2010, zefram@fysh.org wrote:
> 
> This is a bug report for perl from zefram@vigo.rous.org,
> generated with the help of perlbug 1.39 running under perl 5.12.0.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> The G_KEEPERR flag is meant to prevent an exception thrown from within
> some code from affecting an outer $@.  It is used, for example, when
> calling a DESTROY method, as shown here with the End module from CPAN:
> 
> $ perl -MEnd -lwe 'eval { my $x = end { die "aa\n" }; die "bb\n";};
>    print "outer err=", $@'
> 	(in cleanup) aa
> outer err=bb
> 	(in cleanup) aa
> 
> (This suffers from double reporting, but that's an issue for another
> ticket.)  However, if the main exception is a non-string object, it
>    gets
> squashed by the cleanup exception:
> 
> $ perl -MEnd -lwe 'eval { my $x = end { die "aa\n" }; die {};}; print
>    "outer err=", $@'
> 	(in cleanup) aa
> outer err=	(in cleanup) aa
> 
> This is contrary to the description of G_KEEPERR.  A similar outcome,
> lacking the warning, occurs if the cleanup exception is not a string:
> 
> $ perl -MEnd -lwe 'eval { my $x = end { die [] }; die "bb\n";}; print
>    "outer err=", $@'
> outer err=ARRAY(0x804e5b0)
> $ perl -MEnd -lwe 'eval { my $x = end { die [] }; die {};}; print
>    "outer err=", $@'
> outer err=ARRAY(0x8065c20)
> 
> The KEEPERR logic is very dependent on the exceptions being strings.
> perlcall(1) says the flag dates from perl 5.002, so this is
> understandable.  It needs revision for the brave new world of, er,
>    5.005.

This was all fixed by your changes, wasn’t it?

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=74538

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About