Bug#627376: vim: noshelltemp option truncates command output

Alan Curry pacman at kosh.dhis.org
Fri May 20 08:07:35 UTC 2011

Package: vim
Version: 2:7.2.445+hg~cb94c42c0e1a-1
Severity: normal

This is a timing-sensitive bug, hard to reproduce. But after running into it
a few times, I finally came up with a simple test case that does the wrong
thing consistently for me. I hope this procedure makes it possible for others
to see it too:

Start up vim. :set noshelltmp. Insert the following long line into the edit

sleep 3;printf '%s\n' xxxxxxx000 xxxxxxx001 xxxxxxx002 xxxxxxx003 xxxxxxx004 xxxxxxx005 xxxxxxx006 xxxxxxx007 xxxxxxx008 xxxxxxx009 xxxxxxx010 xxxxxxx011 xxxxxxx012 xxxxxxx013 xxxxxxx014 xxxxxxx015 xxxxxxx016 xxxxxxx017 xxxxxxx018

Run !!sh on that line. The command's output is truncated, with only a couple
of x's on the last line instead of xxxxxxx018. If you don't see the bug, try
a few more times, run a CPU-hogging program at the same time, and strace the
vim process. Anything that shakes up the timing can help bring out the bug.

I've been looking at mch_call_shell in os_unix.c, which is the likely
location of the bug, and I haven't figured everything out yet, but it looks
like the loops are ending prematurely. The inner while(RealWaitForChar(...))
loop could be ending because of the gettimeofday check (whose purpose I don't
understand, and this is made harder to study by the fact that strace no
longer shows gettimeofday!) Note that it has a 2 second threshold, and that I
used a sleep 3 to trigger the bug. I think those are related. With a sleep 1
instead I don't see the bug.

The outer for(;;) loop has a specific "Don't break the loop yet" comment
referring to "might still be something to read", but it doesn't seem to be
working since the loop is ended before everything has been read.

-- System Information:
Debian Release: 6.0.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.37+
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages vim depends on:
ii  libacl1      2.2.49-4                    Access control list shared library
ii  libc6        2.11.2-10                   Embedded GNU C Library: Shared lib
ii  libgpm2      1.20.4-3.3                  General Purpose Mouse - shared lib
ii  libncurses5  5.7+20100313-5              shared libraries for terminal hand
ii  libselinux1  2.0.96-1                    SELinux runtime shared libraries
ii  vim-common   2:7.2.445+hg~cb94c42c0e1a-1 Vi IMproved - Common files
ii  vim-runtime  2:7.2.445+hg~cb94c42c0e1a-1 Vi IMproved - Runtime files

vim recommends no packages.

Versions of packages vim suggests:
ii  exuberant-ctags [ctags]  1:5.8-3squeeze1 build tag file indexes of source c
pn  vim-doc                  <none>          (no description available)
pn  vim-scripts              <none>          (no description available)

-- no debconf information

More information about the pkg-vim-maintainers mailing list