develooper Front page | perl.perl5.porters | Postings from May 2004

Re: [perl #29851] Problem with Carp and Safe

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
May 30, 2004 14:24
Subject:
Re: [perl #29851] Problem with Carp and Safe
Message ID:
20040530213042.GB1901@iabyn.com
On Tue, May 25, 2004 at 10:29:04AM -0000, Lionel CONS wrote:
> Some old code of mine stopped working on recent versions of Perl.
> After debugging, the problem seems to be in some incompatibility
> between Carp and Safe.

Thanks for the report.

Carp will sometimes do:

    { local $@; require Carp::Heavy; }

Since require isn't allowed within the compartment, Perl raises an exception;
control is unwound to the eval done by the Safe::reval, then all the saved
stuff like the local()s are unwound, thus blowing away the error message
in $@.

A similar result can be seen with this:

    sub foo {
	print("starting foo\n");
	{ local $@; require XXX; }
	print("exiting foo\n");
    }
    $| = 1;
    eval("foo()");
    die("trapped: [[$@]]\n") if $@;
    print "at end\n";

which outputs:

    starting foo
    at end

As to how to fix this, or whether it needs fixing, I don't know. Anyone
else want to voice their opinions?




-- 
You never really learn to swear until you learn to drive.

Thread Previous | 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