From c304acb49dada68ec331d50f8af45f0dda83ba6a Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Mon, 29 Aug 2022 13:57:58 +0200 Subject: pp_ctl.c - use try_yyparse() for eval CATCH_GET is never true in this code, so we never called try_yyparse() which in turn meant we leaked debug data from failed evals. With this in place an eval that dies during compile will always be handled by doeval_comp() properly. This includes changes to t/comp/readlines.t so it tests code that croaks during compile, which used to leak and fail test but was not actually tested. This fixes GH Issue #20161. --- pp_ctl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'pp_ctl.c') diff --git a/pp_ctl.c b/pp_ctl.c index f3e4f29f8f..68c22ff490 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3686,12 +3686,13 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) CALL_BLOCK_HOOKS(bhk_eval, saveop); - /* note that yyparse() may raise an exception, e.g. C, - * so honour CATCH_GET and trap it here if necessary */ - - + /* we should never be CATCH_GET true here, as our immediate callers should + * always handle that case. */ + assert(!CATCH_GET); /* compile the code */ - yystatus = (!in_require && CATCH_GET) ? S_try_yyparse(aTHX_ GRAMPROG) : yyparse(GRAMPROG); + yystatus = (!in_require) + ? S_try_yyparse(aTHX_ GRAMPROG) + : yyparse(GRAMPROG); if (yystatus || PL_parser->error_count || !PL_eval_root) { PERL_CONTEXT *cx; @@ -4578,6 +4579,8 @@ PP(pp_entereval) if (CATCH_GET) return docatch(Perl_pp_entereval); + assert(!CATCH_GET); + gimme = GIMME_V; was = PL_breakable_sub_gen; saved_delete = FALSE; -- cgit v1.2.1