Hi Bram and list,
When registered partial callback and called callback, Vim SEGV.
how to reproduce:
$ cat test.vim
let s:meow = {}
function! s:meow.bite(...)
endfunction
call timer_start(100, s:meow.bite)
--
$ vim -Nu NONE -S test.vim
Vim: Caught deadly signal SEGV
Segmentation fault (core dumped)
I wrote a patch.
get_callback() forgot increment partial reference counter.
I add it.
And get_callback() is called job function.
Therefore, The job's callback issue also would have fixed.
Please check this.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/eval.c b/src/eval.c
index 2256589..06f3585 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -20190,6 +20190,7 @@ get_callback(typval_T *arg, partial_T **pp)
if (arg->v_type == VAR_PARTIAL && arg->vval.v_partial != NULL)
{
*pp = arg->vval.v_partial;
+ ++(*pp)->pt_refcount;
return (*pp)->pt_name;
}
*pp = NULL;
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index 9f58a35..7ef51e5 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -30,3 +30,16 @@ func Test_repeat_many()
call assert_true(s:val > 1)
call assert_true(s:val < 5)
endfunc
+
+func Test_with_partial_callback()
+ let s:val = 0
+ let s:meow = {}
+ function s:meow.bite(...)
+ let s:val += 1
+ endfunction
+
+ call timer_start(50, s:meow.bite)
+ sleep 200m
+ call assert_equal(1, s:val)
+endfunc
+" vim: ts=2 sw=0 et