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

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

Thread Previous | Thread Next
Dave Mitchell
May 30, 2004 14:24
Re: [perl #29851] Problem with Carp and Safe
Message ID:
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;
    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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About