diff options
author | erw7 <erw7.github@gmail.com> | 2020-06-22 23:17:20 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 10:17:20 -0400 |
commit | 21453e8f09b72751d396858b9ea86c0584fd6c89 (patch) | |
tree | 38273aab781fe6542592439d5a4339c1e61911fe | |
parent | 4496628c181e456d57e9257e14d8582d8dc548eb (diff) | |
download | rneovim-21453e8f09b72751d396858b9ea86c0584fd6c89.tar.gz rneovim-21453e8f09b72751d396858b9ea86c0584fd6c89.tar.bz2 rneovim-21453e8f09b72751d396858b9ea86c0584fd6c89.zip |
eval: fix assertion failure in garbage collection (#12436)
* eval: fix assertion failure in garbage collection
fixes #12387, #12430
Lists with CopyID+1 linked only from previous_funccal may be removed in
the garbage collection. Therefore, the terms of the assertions are not
correct. This can be confirmed by the following (The l:x with CopyID+1 of
the first function call needs to be removed by garbage collection):
func! s:f()
let l:x = [1]
let g:x = l:
endfunc
for _ in range(2)
call s:f()
endfor
call garbagecollect()
" press any key
* test: add test for #12387, #12430
-rw-r--r-- | src/nvim/eval/typval_encode.c.h | 2 | ||||
-rw-r--r-- | test/functional/eval/let_spec.lua | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index 0aa64b1d5f..91c948ce7e 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -364,7 +364,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID, kMPConvList); TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list)); - assert(saved_copyID != copyID && saved_copyID != copyID - 1); + assert(saved_copyID != copyID); _mp_push(*mpstack, ((MPConvStackVal) { .type = kMPConvList, .tv = tv, diff --git a/test/functional/eval/let_spec.lua b/test/functional/eval/let_spec.lua index f8fcdfd41f..5bc703b567 100644 --- a/test/functional/eval/let_spec.lua +++ b/test/functional/eval/let_spec.lua @@ -75,4 +75,19 @@ describe(':let', function() command(cmd_get_child_env) eq(eval('$NVIM_TEST'), eval('g:env_from_child')) end) + + it("release of list assigned to l: variable does not trigger assertion #12387, #12430", function() + source([[ + func! s:f() + let l:x = [1] + let g:x = l: + endfunc + for _ in range(2) + call s:f() + endfor + call garbagecollect() + call feedkeys('i', 't') + ]]) + eq(1, eval('1')) + end) end) |