Front page | perl.perl5.porters |
Postings from September 2000
Re: Tiny 2-byte change to fix debugger's eval bug
Thread Previous
|
Thread Next
From:
Ilya Zakharevich
Date:
September 27, 2000 15:54
Subject:
Re: Tiny 2-byte change to fix debugger's eval bug
Message ID:
20000927185449.A24927@monk.mps.ohio-state.edu
On Thu, Mar 16, 2000 at 05:13:00PM -0500, ilya wrote:
> Tom Christiansen writes:
> > package Mod;
> > eval { die "ok\n"; };
> > unless ($@ && $@ eq "ok\n") {
> > die "Keep your hands off my exceptions, you freak: $@";
> > }
> > 1;
>
> > % perl -de 'require Mod; 1'
> > [...]
> > main::(-e:1): require Mod; 1
> > DB<1> c
> > Keep your hands off my exceptions, you freak: ok
> > require 0 called at Mod.pm line 2
> > require Mod.pm called at -e line 1
> > require Mod.pm called at -e line 1
> > Compilation failed in require at -e line 1, <IN> line 1.
> > Debugged program terminated. Use q to quit or R to restart,
> > use O inhibit_exit to avoid stopping after program termination,
> > h q, h R or h O to get additional info.
>
> Looks like a bug. Now what it is? $^S not propagating through require?
Was a bug indeed. Insider require() $^S was always left undefined.
A fix [for 5.005_60] follows. Have no time (at least today) to retest
under 5.7.0...
Enjoy,
Ilya
--- ./pp_ctl.c~ Mon Aug 2 04:09:57 1999
+++ ./pp_ctl.c Wed Sep 27 18:30:21 2000
@@ -2529,7 +2529,9 @@ S_doeval(pTHX_ int gimme, OP** startop)
AV* comppadlist;
I32 i;
- PL_in_eval = EVAL_INEVAL;
+ PL_in_eval = ((saveop && saveop->op_type == OP_REQUIRE)
+ ? (EVAL_INREQUIRE | (PL_in_eval & EVAL_INEVAL))
+ : EVAL_INEVAL);
PUSHMARK(SP);
@@ -2686,6 +2688,7 @@ S_doeval(pTHX_ int gimme, OP** startop)
CvDEPTH(PL_compcv) = 1;
SP = PL_stack_base + POPMARK; /* pop original mark */
PL_op = saveop; /* The caller may need it. */
+ PL_lex_state = LEX_NOTPARSING; /* $^S needs this. */
#ifdef USE_THREADS
MUTEX_LOCK(&PL_eval_mutex);
PL_eval_owner = 0;
--- ./mg.c~ Mon Aug 2 03:04:21 1999
+++ ./mg.c Wed Sep 27 18:32:12 2000
@@ -497,10 +497,8 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
dTHR;
if (PL_lex_state != LEX_NOTPARSING)
SvOK_off(sv);
- else if (PL_in_eval)
- sv_setiv(sv, 1);
else
- sv_setiv(sv, 0);
+ sv_setiv(sv, PL_in_eval & ~(EVAL_INREQUIRE));
}
break;
case '\024': /* ^T */
--- ./cop.h~ Wed Aug 4 22:44:11 1999
+++ ./cop.h Wed Sep 27 18:28:11 2000
@@ -306,6 +306,7 @@ struct context {
#define EVAL_INEVAL 1 /* some enclosing scope is an eval */
#define EVAL_WARNONLY 2 /* used by yywarn() when calling yyerror() */
#define EVAL_KEEPERR 4 /* set by Perl_call_sv if G_KEEPERR */
+#define EVAL_INREQUIRE 8 /* The code is being required. */
/* Support for switching (stack and block) contexts.
* This ensures magic doesn't invalidate local stack and cx pointers.
--- ./util.c~ Mon Aug 2 12:07:43 1999
+++ ./util.c Wed Sep 27 18:39:33 2000
@@ -3391,7 +3391,7 @@ Perl_new_struct_thread(pTHX_ struct perl
PL_start_env.je_mustcatch = TRUE;
PL_top_env = &PL_start_env;
- PL_in_eval = EVAL_NULL; /* ~(EVAL_INEVAL|EVAL_WARNONLY|EVAL_KEEPERR) */
+ PL_in_eval = EVAL_NULL; /* ~(EVAL_INEVAL|EVAL_WARNONLY|EVAL_KEEPERR|EVAL_INREQUIRE) */
PL_restartop = 0;
PL_statname = NEWSV(66,0);
Thread Previous
|
Thread Next