Dominique Pelle wrote:

> I tried running tests with valgrind using
> vim-7.4.1862 huge gtk2 and it found bugs.
> 
> In test_channel.vim:
> 
> ==22619== Memcheck, a memory error detector
> ==22619== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
> ==22619== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
> ==22619== Command: ../vim -f -u unix.vim -U NONE --noplugin
> --not-a-term -u NONE -U NONE -S runtest.vim test_channel.vim
> ==22619== Parent PID: 22618
> ==22619==
> ==22619== Invalid read of size 1
> ==22619==    at 0x4C2E0E2: strlen (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22619==    by 0x4C2C51: get_emsg_source (message.c:418)
> ==22619==    by 0x4C2B3F: msg_source (message.c:462)
> ==22619==    by 0x4C2FB0: emsg (message.c:614)
> ==22619==    by 0x438E23: partial_free (eval.c:5967)
> ==22619==    by 0x438E23: partial_unref (eval.c:5980)
> ==22619==    by 0x5EA706: channel_clear_one (channel.c:2679)
> ==22619==    by 0x5EA4F7: channel_clear (channel.c:2693)
> ==22619==    by 0x5EA7E7: channel_free_all (channel.c:2714)
> ==22619==    by 0x4D9662: free_all_mem (misc2.c:1222)

This happens because of the order in which memory is freed.  I'll set
really_exiting and skip the error message.

> ==22619==    by 0x514755: mch_exit (os_unix.c:3285)
> ==22619==    by 0x4788A5: ex_quit_all (ex_docmd.c:7125)
> ==22619==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==22619==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==22619==    by 0x4690B1: do_source (ex_cmds2.c:3936)
> ==22619==    by 0x468813: cmd_source (ex_cmds2.c:3549)
> ==22619==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==22619==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==22619==    by 0x5F281C: exe_commands (main.c:2933)
> ==22619==    by 0x5F281C: main (main.c:955)
> ==22619==  Address 0xcdc2760 is 0 bytes inside a block of size 41 free'd
> ==22619==    at 0x4C2BDEC: free (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==22619==    by 0x46974F: free_scriptnames (ex_cmds2.c:4068)
> ==22619==    by 0x42FEF4: eval_clear (eval.c:1027)
> ==22619==    by 0x4D965D: free_all_mem (misc2.c:1219)
> ==22619==    by 0x514755: mch_exit (os_unix.c:3285)
> ==22619==    by 0x4788A5: ex_quit_all (ex_docmd.c:7125)
> ==22619==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==22619==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==22619==    by 0x4690B1: do_source (ex_cmds2.c:3936)
> ==22619==    by 0x468813: cmd_source (ex_cmds2.c:3549)
> ==22619==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==22619==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==22619==    by 0x5F281C: exe_commands (main.c:2933)
> ==22619==    by 0x5F281C: main (main.c:955)
> (more errors after that)

I see memory leaks here.

> And in test49.vim:
> 
> ==21299== Memcheck, a memory error detector
> ==21299== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
> ==21299== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
> ==21299== Command: ../vim -f -u unix.vim -U NONE --noplugin
> --not-a-term -s dotest.in test49.in
> ==21299== Parent PID: 21298
> ==21299==
> ==21299== Conditional jump or move depends on uninitialised value(s)

I don't see this one.  Perhaps it depends on the set of features?

> ==21299==    at 0x490BF4: buf_write (fileio.c:4349)
> ==21299==    by 0x45C7B7: do_write (ex_cmds.c:2825)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x434638: call_user_func (eval.c:25619)
> ==21299==    by 0x434638: call_func (eval.c:9216)
> ==21299==    by 0x436ABF: get_func_tv (eval.c:9004)
> ==21299==    by 0x435FDB: ex_call (eval.c:3577)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x4690B1: do_source (ex_cmds2.c:3936)
> ==21299==    by 0x468813: cmd_source (ex_cmds2.c:3549)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x4F1063: nv_colon (normal.c:5320)
> ==21299==    by 0x4EA5DC: normal_cmd (normal.c:1149)
> ==21299==    by 0x5F349C: main_loop (main.c:1359)
> ==21299==    by 0x5F2A22: main (main.c:1051)
> ==21299==  Uninitialised value was created by a stack allocation
> ==21299==    at 0x48F06A: buf_write (fileio.c:3121)
> ==21299==
> ==21299==
> ==21299== HEAP SUMMARY:
> ==21299==     in use at exit: 116,764 bytes in 1,109 blocks
> ==21299==   total heap usage: 973,010 allocs, 971,901 frees,
> 18,814,726,893 bytes allocated
> ==21299==
> ==21299== 1 bytes in 1 blocks are definitely lost in loss record 1 of 366

I had seen this one before.  Let's have a look now (running the test
under valgrind is a bit slow...).  Perhaps can replace the empty string
with NULL?  That appears to work.

> ==21299==    at 0x4C2AB80: malloc (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==21299==    by 0x4D8F67: lalloc (misc2.c:920)
> ==21299==    by 0x4D970E: alloc (misc2.c:818)
> ==21299==    by 0x4D970E: vim_strsave (misc2.c:1254)
> ==21299==    by 0x4578B7: eval7 (eval.c:5301)
> ==21299==    by 0x456572: eval6 (eval.c:4941)
> ==21299==    by 0x4561C2: eval5 (eval.c:4757)
> ==21299==    by 0x4559BE: eval4 (eval.c:4475)
> ==21299==    by 0x455874: eval3 (eval.c:4392)
> ==21299==    by 0x432FD3: eval2 (eval.c:4324)
> ==21299==    by 0x432FD3: eval1 (eval.c:4252)
> ==21299==    by 0x4331AB: eval1 (eval.c:4291)
> ==21299==    by 0x43C52E: ex_execute (eval.c:23777)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x46FEC8: do_ucmd (ex_docmd.c:6739)
> ==21299==    by 0x46FEC8: do_one_cmd (ex_docmd.c:2912)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x4690B1: do_source (ex_cmds2.c:3936)
> ==21299==    by 0x468813: cmd_source (ex_cmds2.c:3549)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x4F1063: nv_colon (normal.c:5320)
> ==21299==    by 0x4EA5DC: normal_cmd (normal.c:1149)
> ==21299==    by 0x5F349C: main_loop (main.c:1359)
> ==21299==    by 0x5F2A22: main (main.c:1051)
> ==21299==
> ==21299== 1 bytes in 1 blocks are definitely lost in loss record 2 of 366
> ==21299==    at 0x4C2AB80: malloc (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==21299==    by 0x4D8F67: lalloc (misc2.c:920)
> ==21299==    by 0x4D970E: alloc (misc2.c:818)
> ==21299==    by 0x4D970E: vim_strsave (misc2.c:1254)
> ==21299==    by 0x4578B7: eval7 (eval.c:5301)
> ==21299==    by 0x456572: eval6 (eval.c:4941)
> ==21299==    by 0x4561C2: eval5 (eval.c:4757)
> ==21299==    by 0x4559BE: eval4 (eval.c:4475)
> ==21299==    by 0x455874: eval3 (eval.c:4392)
> ==21299==    by 0x432FD3: eval2 (eval.c:4324)
> ==21299==    by 0x432FD3: eval1 (eval.c:4252)
> ==21299==    by 0x43316A: eval1 (eval.c:4273)
> ==21299==    by 0x43C52E: ex_execute (eval.c:23777)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x46FEC8: do_ucmd (ex_docmd.c:6739)
> ==21299==    by 0x46FEC8: do_one_cmd (ex_docmd.c:2912)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x4690B1: do_source (ex_cmds2.c:3936)
> ==21299==    by 0x468813: cmd_source (ex_cmds2.c:3549)
> ==21299==    by 0x46F51D: do_one_cmd (ex_docmd.c:2921)
> ==21299==    by 0x46B000: do_cmdline (ex_docmd.c:1107)
> ==21299==    by 0x4F1063: nv_colon (normal.c:5320)
> ==21299==    by 0x4EA5DC: normal_cmd (normal.c:1149)
> ==21299==    by 0x5F349C: main_loop (main.c:1359)
> ==21299==    by 0x5F2A22: main (main.c:1051)
> ==21299==
> 
> 
> The test also ended with errors:
> 
> 2 FAILED:
> Found errors in Test_cursorhold_insert():
> function RunTheTest[9]..Test_cursorhold_insert line 6: Expected 1 but got 0
> Found errors in Test_repeat_three():
> Caught exception in Test_repeat_three(): Vim(sleep):E118: Too many
> arguments for function: string @ function
> RunTheTest[9]..Test_repeat_three, line 3
> test61 FAILED
> 
> >From test_alot.vim:
> Found errors in Test_cursorhold_insert():
> function RunTheTest[9]..Test_cursorhold_insert line 6: Expected 1 but got 0
> Found errors in Test_repeat_three():
> Caught exception in Test_repeat_three(): Vim(sleep):E118: Too many
> arguments for function: string @ function
> RunTheTest[9]..Test_repeat_three, line 3
> 
> Test results:
> test61 FAILED
> 
> >From test_alot.vim:
> Found errors in Test_cursorhold_insert():
> function RunTheTest[9]..Test_cursorhold_insert line 6: Expected 1 but got 0
> Found errors in Test_repeat_three():
> Caught exception in Test_repeat_three(): Vim(sleep):E118: Too many
> arguments for function: string @ function
> RunTheTest[9]..Test_repeat_three, line 3
> TEST FAILURE
> make: *** [report] Error 1
> 
> I don't have time to investigate now, but
> I should find the time during the weekend.

I may have some time for this tomorrow.  But I don't see the test
failures.  I hope you can find the conditions to reproduce these.

-- 
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
                -- Arthur Dent and Ford Prefect in Douglas Adams'
                   "The Hitchhiker's Guide to the Galaxy"

 /// 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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui