From 069abe75ae564d7bac9bdf9eeac40f3ca9447539 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 3 Nov 2013 17:24:50 -0800 Subject: [PATCH] Stop CORE::GLOBAL::do lookup from crashing on stub MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ‘sub CORE::GLOBAL::do;’ doesn’t create a full glob, but cheats for efficiency. Compilation of do-file ops was not taking this into account. --- op.c | 1 + t/op/override.t | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/op.c b/op.c index 40df34a..ee917b4 100644 --- a/op.c +++ b/op.c @@ -5478,6 +5478,7 @@ Perl_dofile(pTHX_ OP *term, I32 force_builtin) if (!(gv && GvCVu(gv) && GvIMPORTED_CV(gv))) { GV * const * const gvp = (GV**)hv_fetchs(PL_globalstash, "do", FALSE); gv = gvp ? *gvp : NULL; + if (gv && !isGV(gv)) gv_init(gv, PL_globalstash, "do", 2, 0); } } diff --git a/t/op/override.t b/t/op/override.t index 90510dd..16aec74 100644 --- a/t/op/override.t +++ b/t/op/override.t @@ -4,9 +4,11 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; + require Config; # load these before we mess with *CORE::GLOBAL::require + require 'Config_heavy.pl'; # since runperl will need them } -plan tests => 29; +plan tests => 30; # # This file tries to test builtin override using CORE::GLOBAL @@ -150,3 +152,7 @@ BEGIN { package other; *::caller = \&::caller } sub caller() { 42 } caller; # inline the constant is caller, 42, 'constant inlining does not undo "use subs" on keywords'; + +is runperl(prog => 'sub CORE::GLOBAL::do; do file; print qq-ok\n-'), + "ok\n", + 'no crash with CORE::GLOBAL::do stub'; -- 2.7.4