Skip to content

Commit

Permalink
[perl #107636] Make Carp::longmess work inside die override
Browse files Browse the repository at this point in the history
When PL_last_in_gv (and hence $.) is set, Carp::longmess uses
eval { die } to find out what handle and line number perl will append
to the error message.

It was not qualifying the die with CORE::, so a CORE::GLOBAL::die
override that itself calls Carp::longmess would result in infinite
recursion if that override were installed before Carp loaded.

This broke Class::Scaffold’s tests, which began to hang.
  • Loading branch information
Father Chrysostomos committed Apr 20, 2012
1 parent cc33632 commit 781fa0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/Carp/lib/Carp.pm
Expand Up @@ -291,7 +291,7 @@ sub ret_backtrace {
local $@ = '';
local $SIG{__DIE__};
eval {
die;
CORE::die;
};
if($@ =~ /^Died at .*(, <.*?> line \d+).$/ ) {
$mess .= $1;
Expand Down
16 changes: 15 additions & 1 deletion dist/Carp/t/Carp.t
Expand Up @@ -3,7 +3,7 @@ no warnings "once";
use Config;

use IPC::Open3 1.0103 qw(open3);
use Test::More tests => 59;
use Test::More tests => 60;

sub runperl {
my(%args) = @_;
Expand Down Expand Up @@ -430,6 +430,20 @@ $@ =~ s/\n.*//; # just check first line
is $@, "heek at ".__FILE__." line ".(__LINE__-2).", <DATA> line 2.\n",
'last handle line num is mentioned';

like(
runperl(
prog => q<
open FH, q-Makefile.PL-;
<FH>; # set PL_last_in_gv
BEGIN { *CORE::GLOBAL::die = sub { die Carp::longmess(@_) } };
use Carp;
die fumpts;
>,
),
qr 'fumpts',
'Carp::longmess works inside CORE::GLOBAL::die',
);


# New tests go here

Expand Down

0 comments on commit 781fa0f

Please sign in to comment.