New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carp inadvertently autovivifies CORE::GLOBAL::caller #10672
Comments
From @arcCreated by @arcAs of bf236c8, lib/Carp.pm contains a bare The attached patch fixes that, and adds a test to prevent it happening again. Perl Info
|
From @arc0001-lib-Carp.pm-Avoid-autovivification-of-CORE-GLOBAL-ca.patchFrom 93553813cde1bf59b3422a33435f467cc3c23dfb Mon Sep 17 00:00:00 2001
From: Aaron Crane <arc@cpan.org>
Date: Mon, 27 Sep 2010 12:02:01 +0100
Subject: [PATCH] lib/Carp.pm: Avoid autovivification of CORE::GLOBAL::caller
And add a test to prevent this happening again.
---
lib/Carp.pm | 3 ++-
lib/Carp.t | 9 +++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/Carp.pm b/lib/Carp.pm
index 0e9105a..6aba427 100644
--- a/lib/Carp.pm
+++ b/lib/Carp.pm
@@ -86,7 +86,8 @@ sub caller_info {
@DB::args = (); # Don't let anyone see the address of $i
local $@;
my $where = eval {
- my $gv = B::svref_2object(\&CORE::GLOBAL::caller)->GV;
+ my $func = defined &{"CORE::GLOBAL::caller"} ? \&{"CORE::GLOBAL::caller"} : return '';
+ my $gv = B::svref_2object($func)->GV;
my $package = $gv->STASH->NAME;
my $subname = $gv->NAME;
return unless defined $package && defined $subname;
diff --git a/lib/Carp.t b/lib/Carp.t
index 1c59987..8240cd3 100644
--- a/lib/Carp.t
+++ b/lib/Carp.t
@@ -11,9 +11,14 @@ my $Is_VMS = $^O eq 'VMS';
use Carp qw(carp cluck croak confess);
-plan tests => 56;
+BEGIN {
+ plan tests => 56;
-ok 1;
+ # This test must be run at BEGIN time, because code later in this file
+ # sets CORE::GLOBAL::caller
+ ok !exists $CORE::GLOBAL::{caller},
+ "Loading doesn't create CORE::GLOBAL::caller"
+}
{ local $SIG{__WARN__} = sub {
like $_[0], qr/ok (\d+)\n at.+\b(?i:carp\.t) line \d+$/, 'ok 2\n' };
--
1.7.3
|
From @cpansproutOn Mon Sep 27 04:19:47 2010, arc wrote:
Thank you. I’ve applied this as 39d0b21ca5a59dba7652555c425faec6c7a5e653. |
The RT System itself - Status changed from 'new' to 'open' |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#78082 (status was 'resolved')
Searchable as RT78082$
The text was updated successfully, but these errors were encountered: