Luc Hermitte <[email protected]> wrote:

> Hi,
>
> I've been playing with job_start to see what can be achieved with it, and I 
> observe a crash with the following code on vim 7.4-1829 (compiled on an 
> ubuntu x89_64 machine)
>
> It seems related to the fact I use a dict function as callback.
> I may no have the correct syntax, yet the crash is certainly not a correct 
> behaviour.
>
> The backtrace is:
> ------------ >% ------------
> ======= Backtrace: =========
> /lib/x86_64-linux-gnu/libc.so.6(+0x7db26)[0x7f4aeaa83b26]
> gvim[0x47d165]
> gvim(dict_unref+0x2f)[0x47d1df]
> gvim(partial_unref+0x5a)[0x47c24a]
> gvim(channel_close+0x1a3)[0x5f64a3]
> gvim(channel_parse_messages+0xf4)[0x5f7064]
> gvim(parse_queued_messages+0x13)[0x50bd23]
> gvim(gui_mch_wait_for_chars+0x3b)[0x5de07b]
> gvim[0x5ce86b]
> gvim(gui_wait_for_chars+0x87)[0x5d0647]
> gvim(ui_inchar+0xe4)[0x5bda04]
> gvim(inchar+0x12f)[0x4d3ccf]
> gvim[0x4d5cc9]
> gvim(vgetc+0x16d)[0x4d64bd]
> gvim(safe_vgetc+0x9)[0x4d6859]
> gvim(normal_cmd+0xed)[0x5217bd]
> gvim(main_loop+0x375)[0x5fda15]
> gvim(main+0x1474)[0x44c264]
> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f4aeaa2776d]
> gvim[0x44d58d]
> ------------ >% ------------
>
>
> and the (semi-minimalist) test program is the following
> ------------ >% ------------
> " Attempt at non-interactive background compilation
> "
> " Compilation messages are analysed at the end of the compilation process
>
> function! s:conclude(channel) abort
>   echomsg "Compilation finished"
>   exe 'cgetfile ' . s:buffer
> endfunction
>
> function! Build_comp(nb)
>   let comp = {}
>
>   " redundant version that crashes vim as well.
>   function! comp.conclude(channel) dict abort
>     echomsg "Compilation finished"
>     exe 'cgetfile ' . self.buffer
>   endfunction
>   let comp.conclude = function('s:conclude')
>
>   function! comp.init(nb) dict abort
>     " let self.buffer = tempname()
>     let s:buffer = tempname()
>     " tests/lh/repeat-wait.sh prints stuff to stdout
>     let self.job = job_start(['tests/repeat-wait.sh', a:nb],
>           \ { 'out_io': 'file', 'out_name': s:buffer
>           \ , 'close_cb': function('s:conclude', self)} )
>     " let self.job = job_start(['tests/repeat-wait.sh', 2],
>           " \ { 'out_io': 'file', 'out_name': self.buffer
>           " \ , 'close_cb': function('self.conclude', self)} )
>   endfunction
>
>   return comp.init(a:nb)
> endfunction
> ------------ >% ------------


Hi Luc

I can reproduce the crash in Vim-7.4.1829 by sourcing
your script and running:

   :call Build_comp(1)

Valgrind gives this error:

==7552== Invalid read of size 8
==7552==    at 0x445130: dict_free_contents (eval.c:7494)
==7552==    by 0x4451EA: dict_free (eval.c:7526)
==7552==    by 0x4451EA: dict_unref (eval.c:7475)
==7552==    by 0x444159: partial_free (eval.c:5956)
==7552==    by 0x444159: partial_unref (eval.c:5970)
==7552==    by 0x5B6B11: channel_close (channel.c:2574)
==7552==    by 0x5B76D8: channel_close_now (channel.c:2877)
==7552==    by 0x5B76D8: channel_parse_messages (channel.c:3596)
==7552==    by 0x4D66A2: parse_queued_messages (misc2.c:6237)
==7552==    by 0x50C6C9: mch_inchar (os_unix.c:390)
==7552==    by 0x589187: ui_inchar (ui.c:195)
==7552==    by 0x49D76E: inchar (getchar.c:3056)
==7552==    by 0x49F782: vgetorpeek (getchar.c:2832)
==7552==    by 0x49FFFF: vgetc (getchar.c:1605)
==7552==    by 0x4A0378: safe_vgetc (getchar.c:1801)
==7552==    by 0x4EC41D: normal_cmd (normal.c:627)
==7552==    by 0x5BE30C: main_loop (main.c:1359)
==7552==    by 0x413433: main (main.c:1051)
==7552==  Address 0xdd515f0 is 192 bytes inside a block of size 336 free'd
==7552==    at 0x4C2BDEC: free (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7552==    by 0x444159: partial_free (eval.c:5956)
==7552==    by 0x444159: partial_unref (eval.c:5970)
==7552==    by 0x5B5419: channel_clear (channel.c:2658)
==7552==    by 0x5B6BA5: channel_free_contents (channel.c:390)
==7552==    by 0x5B6BF0: channel_free (channel.c:417)
==7552==    by 0x5B6C3F: channel_may_free (channel.c:434)
==7552==    by 0x5B6C3F: channel_unref (channel.c:449)
==7552==    by 0x5B90AF: job_unref (channel.c:4225)
==7552==    by 0x444200: clear_tv (eval.c:22459)
==7552==    by 0x44515C: dict_free_contents (eval.c:7500)
==7552==    by 0x4451EA: dict_free (eval.c:7526)
==7552==    by 0x4451EA: dict_unref (eval.c:7475)
==7552==    by 0x444159: partial_free (eval.c:5956)
==7552==    by 0x444159: partial_unref (eval.c:5970)
==7552==    by 0x5B6B11: channel_close (channel.c:2574)
==7552==    by 0x5B76D8: channel_close_now (channel.c:2877)
==7552==    by 0x5B76D8: channel_parse_messages (channel.c:3596)
==7552==    by 0x4D66A2: parse_queued_messages (misc2.c:6237)
==7552==    by 0x50C6C9: mch_inchar (os_unix.c:390)
==7552==    by 0x589187: ui_inchar (ui.c:195)
==7552==    by 0x49D76E: inchar (getchar.c:3056)
==7552==    by 0x49F782: vgetorpeek (getchar.c:2832)
==7552==    by 0x49FFFF: vgetc (getchar.c:1605)
==7552==    by 0x4A0378: safe_vgetc (getchar.c:1801)
==7552==    by 0x4EC41D: normal_cmd (normal.c:627)
==7552==    by 0x5BE30C: main_loop (main.c:1359)
==7552==    by 0x413433: main (main.c:1051)
(and more errors after that)

Dominique

-- 
-- 
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