diff options
author | Yves Orton <demerphq@gmail.com> | 2022-08-29 13:57:58 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-09-05 07:57:17 +0200 |
commit | c304acb49dada68ec331d50f8af45f0dda83ba6a (patch) | |
tree | 70b5ae92d3e3c233154bf1d4fb556965509880c5 /pp_ctl.c | |
parent | aeff225d87d2f29d88da7859578fe95761d0a347 (diff) | |
download | perl-c304acb49dada68ec331d50f8af45f0dda83ba6a.tar.gz |
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.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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<BEGIN{die}>, - * 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; |