Yegappan wrote:

> When running Vim under valgrind, if the following Vim9 script
> is sourced:
> 
> =================================
> vim9script
> def Func1(pat_arg: string)
>   echo pat_arg
> enddef
> Func1('*.c')
> =================================
> 
> The following traceback is reported:
> 
> ==33841== Conditional jump or move depends on uninitialised value(s)
> ==33841==    at 0x5D7E47: typval2type (vim9type.c:312)
> ==33841==    by 0x5D874F: check_typval_type (vim9type.c:354)
> ==33841==    by 0x5D2927: call_def_function (vim9execute.c:795)
> ==33841==    by 0x5C3059: call_user_func (userfunc.c:1319)
> ==33841==    by 0x5C36D3: call_user_func_check (userfunc.c:1711)
> ==33841==    by 0x5C3B5F: call_func (userfunc.c:2179)
> ==33841==    by 0x5C3FD2: get_func_tv (userfunc.c:690)
> ==33841==    by 0x45198B: eval_func (eval.c:1900)
> ==33841==    by 0x455F9A: eval7 (eval.c:3256)
> ==33841==    by 0x456440: eval6 (eval.c:2895)
> ==33841==    by 0x456440: eval5 (eval.c:2670)
> ==33841==    by 0x4569BB: eval4 (eval.c:2532)
> ==33841==    by 0x456FAE: eval3 (eval.c:2385)
> ==33841==    by 0x456FAE: eval2 (eval.c:2251)
> ==33841==    by 0x456FAE: eval1 (eval.c:2109)
> 
> This is seen with Vim 8.2.1666.

I have noticed this in a few places.  The problem is that often a
typval_T is passed to the evaluation functions and only v_type is
initialized.  Or nothing at all.  Then when accessing any of the fields,
possibly when evaluation failed or didn't set v_lock, a field is read
that wasn't initialized.

It might be the best to initialize rettv in eval0().  It might be a bit
of extra work in case evaluation fails, but that's not relevant.

-- 
Any sufficiently advanced technology is indistinguishable from magic.
                                        Arthur C. Clarke
Any sufficiently advanced bug is indistinguishable from a feature.
                                        Rich Kulawiec

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202009122010.08CKAf1p1214715%40masaka.moolenaar.net.

Raspunde prin e-mail lui