comparison src/vim9execute.c @ 25078:eac6e5a94e9d v8.2.3076

patch 8.2.3076: Vim9: using try in catch block causes a hang Commit: https://github.com/vim/vim/commit/3f987b59173926420998ca92eb71688ee3e4a3e3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 30 12:02:24 2021 +0200 patch 8.2.3076: Vim9: using try in catch block causes a hang Problem: Vim9: using try in catch block causes a hang. Solution: Save and restore the ec_in_catch flag. (closes https://github.com/vim/vim/issues/8478)
author Bram Moolenaar <Bram@vim.org>
date Wed, 30 Jun 2021 12:15:04 +0200
parents 70f55a30f03c
children 146c9720e563
comparison
equal deleted inserted replaced
25077:3438b2048ba7 25078:eac6e5a94e9d
24 24
25 // Structure put on ec_trystack when ISN_TRY is encountered. 25 // Structure put on ec_trystack when ISN_TRY is encountered.
26 typedef struct { 26 typedef struct {
27 int tcd_frame_idx; // ec_frame_idx at ISN_TRY 27 int tcd_frame_idx; // ec_frame_idx at ISN_TRY
28 int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY 28 int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY
29 int tcd_save_in_catch; // saved ec_in_catch
29 int tcd_catch_idx; // instruction of the first :catch or :finally 30 int tcd_catch_idx; // instruction of the first :catch or :finally
30 int tcd_finally_idx; // instruction of the :finally block or zero 31 int tcd_finally_idx; // instruction of the :finally block or zero
31 int tcd_endtry_idx; // instruction of the :endtry 32 int tcd_endtry_idx; // instruction of the :endtry
32 int tcd_caught; // catch block entered 33 int tcd_caught; // catch block entered
33 int tcd_cont; // :continue encountered, jump here (minus one) 34 int tcd_cont; // :continue encountered, jump here (minus one)
3164 ++ectx->ec_trystack.ga_len; 3165 ++ectx->ec_trystack.ga_len;
3165 ++trylevel; 3166 ++trylevel;
3166 CLEAR_POINTER(trycmd); 3167 CLEAR_POINTER(trycmd);
3167 trycmd->tcd_frame_idx = ectx->ec_frame_idx; 3168 trycmd->tcd_frame_idx = ectx->ec_frame_idx;
3168 trycmd->tcd_stack_len = ectx->ec_stack.ga_len; 3169 trycmd->tcd_stack_len = ectx->ec_stack.ga_len;
3170 trycmd->tcd_save_in_catch = ectx->ec_in_catch;
3171 ectx->ec_in_catch = FALSE;
3169 trycmd->tcd_catch_idx = 3172 trycmd->tcd_catch_idx =
3170 iptr->isn_arg.try.try_ref->try_catch; 3173 iptr->isn_arg.try.try_ref->try_catch;
3171 trycmd->tcd_finally_idx = 3174 trycmd->tcd_finally_idx =
3172 iptr->isn_arg.try.try_ref->try_finally; 3175 iptr->isn_arg.try.try_ref->try_finally;
3173 trycmd->tcd_endtry_idx = 3176 trycmd->tcd_endtry_idx =
3261 { 3264 {
3262 trycmd_T *trycmd; 3265 trycmd_T *trycmd;
3263 3266
3264 --trystack->ga_len; 3267 --trystack->ga_len;
3265 --trylevel; 3268 --trylevel;
3266 ectx->ec_in_catch = FALSE;
3267 trycmd = ((trycmd_T *)trystack->ga_data) 3269 trycmd = ((trycmd_T *)trystack->ga_data)
3268 + trystack->ga_len; 3270 + trystack->ga_len;
3271 ectx->ec_in_catch = trycmd->tcd_save_in_catch;
3269 if (trycmd->tcd_caught && current_exception != NULL) 3272 if (trycmd->tcd_caught && current_exception != NULL)
3270 { 3273 {
3271 // discard the exception 3274 // discard the exception
3272 if (caught_stack == current_exception) 3275 if (caught_stack == current_exception)
3273 caught_stack = caught_stack->caught; 3276 caught_stack = caught_stack->caught;