Hi.
When starting job with options, out_io=buffer and out_mode=raw, output-buffer
gets garbage output.
[repro steps]
test.vim:
-------
function! s:tm(timer) abort
for i in range(1000)
let a = 1
endfor
if job_status(get(s:, 'job')) !=# 'run'
call timer_stop(a:timer)
endif
endfunction
let s:options = {
\ 'out_mode': 'raw',
\ 'out_io': 'buffer',
\ 'out_name': 'output',
\ }
function! Job() abort
let s:job = job_start(['python3', '-c', 'for _ in range(10000): print(".",
end="", flush=True)'], s:options)
call timer_start(3, function('s:tm'), {'repeat': -1})
endfunction
call Job()
buffer output
-------
vim -Nu NONE -S test.vim
result example:
https://cloud.githubusercontent.com/assets/3213998/16155322/cfc561da-34e9-11e6-868e-6239b76a5107.png
got garbage at end-of-line.
[cause]
https://github.com/vim/vim/blob/688e3d1/src/channel.c#L1619
It sets 'len' to 1,
https://github.com/vim/vim/blob/688e3d1/src/channel.c#L1639
https://github.com/vim/vim/blob/688e3d1/src/channel.c#L1649-L1654
so NUL terminator (of '*p') is overwritten by NL, and it causes buffer-overrun.
[patch]
fix and test.
https://gist.github.com/ichizok/5cb23d48135235983380b97b70b9978a
[additional issue]
test.vim of above outputs multiple lines to buffer, but maybe it is unexpected
and undesired behavior for users.
I think it should not add extra linefeeds; in this case, output should be one
line.
Thank you.
- Ozaki Kiichi
--
--
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.