Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 52116 - vi segmentation fault editing large files
Summary: vi segmentation fault editing large files
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Vim Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-26 11:15 UTC by Vince Van De Coevering
Modified: 2004-08-01 14:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vince Van De Coevering 2004-05-26 11:15:14 UTC
vi is crashing with a segmentation fault when I try to open large (more than a couple of screens of data) files.

-rwxr-xr-x    1 vpv      users       11175 Jul 12  2003 CHANGELOG
-rwxr-xr-x    1 vpv      users        5516 Feb 17  2003 FAQ
-rwxr-xr-x    1 vpv      users        4903 Jul 12  2003 INSTALL
-rwxr-xr-x    1 vpv      users       14948 Jun 17  2000 LICENSE
-rw-r--r--    1 vpv      users        8202 Jul 12  2003 README
-rwxr-xr-x    1 vpv      users       10467 Jun  9  2003 STANDARD

For example:
vi INSTALL works
vi README results in "README"Segmentation fault

I don't know the exact cutoff as to size but I have experienced situations where I added lines using vi, wrote the file to disk, exited vi and was unable to open the file later with vi.  The "sweet spot" seems to be between 8068 and 8208 where vi will edit a file sized at 8068 but segmentation faults on a file sized at 8028 (or larger)  

There is a thread that discusses this issue in the forums at:
http://forums.gentoo.org/viewtopic.php?t=133612&highlight=vi+fault

The remedy discussed in bug 3207 (http://bugs.gentoo.org/show_bug.cgi?id=3207) does not work for this situation.

I'm running a 2.6.x kernel amd reiserfs


Reproducible: Always
Steps to Reproduce:
1. vi filename (if file is more than 4k it crashes)
2.
3.

Actual Results:  
"filename"Segmentation fault

Expected Results:  
expected the vi editor to open and display the contents of the file
Comment 1 Ciaran McCreesh 2004-05-26 11:22:23 UTC
You didn't give us your 'emerge info' output.
Comment 2 Ryan Phillips (RETIRED) gentoo-dev 2004-05-26 14:05:41 UTC
does vi use /var/tmp as it's temporary file location?  It appears from the strace that it does from the forum.  /var/tmp/ is only root writable, perhaps the temporary directory should be /tmp to allow for user writes.

Vince: can you include your strace here also.
Comment 3 Vince Van De Coevering 2004-05-26 15:29:33 UTC
emerge info
Portage 2.0.50-r1 (default-x86-2004.0, gcc-3.3.2, glibc-2.3.2-r9, 2.6.3-gentoo-r1)
=================================================================
System uname: 2.6.3-gentoo-r1 i686 Pentium III (Katmai)
Gentoo Base System version 1.4.3.13
Autoconf: sys-devel/autoconf-2.58-r1
Automake: sys-devel/automake-1.7.7
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -mcpu=i686 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -mcpu=i686 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://gentoo.ccccom.com ftp://mirrors.tds.net/gentoo ftp://ftp.gtlib.cc.gatech.edu/pub/gentoo http://mirror.tucdemonic.org/gentoo/"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="apache2 apm arts avi berkdb crypt cups encode foomaticdb gdbm gif gpm gtk2 imlib jpeg libg++ libwww mad mikmod motif mpeg mysql ncurses nls oggvorbis opengl oss pam perl png python quicktime readline sdl slang spell ssl svga tcpd x86 xml xml2 xmms xv zlib"

I am using vi as the root user (su - from non-root login) so I don't think that would be an issue.

Additional info:
attempting to include a file with :r will fail if the file is too big.  You can :r any number of smaller files but you will receive the segmentation fault when you attempt to write the file

I am not familiar with strace, is there a howto I can use to perform the strace?
Comment 4 Vince Van De Coevering 2004-05-26 15:55:07 UTC
strace results.  This is the exact output, no cr or lf were added

 strace vi README
execve("/usr/bin/vi", ["vi", "README"], [/* 28 vars */]) = 0
uname({sys="Linux", node="gus", ...})   = 0
brk(0)                                  = 0x808d000
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40015000
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=18052, ...}) = 0
mmap2(NULL, 18052, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40016000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 ]\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1304988, ...}) = 0
mmap2(NULL, 1243172, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4001b000
mmap2(0x40145000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x129) = 0x40145000
mmap2(0x40148000, 10276, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40148000
close(3)                                = 0
munmap(0x40016000, 18052)               = 0
open("/dev/urandom", O_RDONLY)          = 3
read(3, "\373\236\345t\t\2a\310\255\305\225\261p\25%|\245,U\364"..., 32) = 32
close(3)                                = 0
ioctl(1, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo ...}) = 0
getpid()                                = 27792
rt_sigaction(SIGHUP, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGHUP, {0x8055880, [], SA_RESTORER|SA_RESTART, 0x400444d8}, {SIG_IGN}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGXFSZ, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTERM, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTERM, {0x8055880, [], SA_RESTORER|SA_RESTART, 0x400444d8}, {SIG_IGN}, 8) = 0
brk(0)                                  = 0x808d000
rt_sigaction(SIGTSTP, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTSTP, {0x8055aa0, [], SA_RESTORER|SA_RESTART, 0x400444d8}, {SIG_IGN}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigaction(SIGINT, {0x8055940, [], SA_RESTORER|SA_RESTART, 0x400444d8}, {SIG_IGN}, 8) = 0
rt_sigaction(SIGTSTP, {0x8055aa0, [], SA_RESTORER|SA_RESTART, 0x400444d8}, {0x8055aa0, [], SA_RESTORER|SA_RESTART, 0x400444d8}, 8) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo ...}) = 0
open("/etc/termcap", O_RDONLY)          = 3
read(3, "######## TERMINAL TYPE DESCRIPTI"..., 2048) = 2048
read(3, "rses suite; it differs from stoc"..., 2048) = 2048
read(3, "or their hardware\n# (notably DEC"..., 2048) = 2048
read(3, " support one attribute without m"..., 2048) = 2048
read(3, "The terminal enquire string <u9>"..., 2048) = 2048
read(3, "w hardware).\n#\n# For the termina"..., 2048) = 2048
read(3, " redistribute freely.\n# There ar"..., 2048) = 2048
read(3, "%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;"..., 2048) = 2048
read(3, "[24m:\\\n\t:tc=klone+sgr:\n\n# For co"..., 2048) = 2048
read(3, ":   Hugh Hansard\n#              "..., 2048) = 2048
read(3, "\\\n\t:li#25:tc=pcansi:\npcansi-33|p"..., 2048) = 2048
read(3, "                           *\n# *"..., 2048) = 2048
read(3, "1%{10}%-%p\'a\'%+%c%e%p1%d%p2%{255"..., 2048) = 2048
read(3, "xxyyzz~~:\\\n\t:ae=\\E(B:al=\\E[L:as="..., 2048) = 2048
read(3, "ion with 43 lines and 132 cols:\\"..., 2048) = 2048
read(3, "H:mb=\\E[5m:\\\n\t:md=\\E[1m:me=\\E[m:"..., 2048) = 2048
read(3, "223s\\224t\\225u\\226v\\227w\\230x\\23"..., 2048) = 2048
read(3, "\\\n\t:AB=\\E[4%p1%dm:AF=\\E[3%p1%dm:"..., 2048) = 2048
read(3, " state (concept at beginning of "..., 2048) = 2048
read(3, "$Op        |  $On    |         |"..., 2048) = 2048
read(3, "=\\E[?7l:RI=\\E[%dC:SA=\\E[?7h:UP=\\"..., 2048) = 2048
read(3, "y (or vt102-nsgr) is probably th"..., 2048) = 2048
read(3, "ys\n# at the top of the keyboard."..., 2048) = 2048
read(3, "o fit entry within 1023 bytes)\n#"..., 2048) = 2048
read(3, "r=\\EM:ta=^I:ue=\\E[24m:up=\\E[A:us"..., 2048) = 2048
read(3, "m:sr=\\EM:st=\\EH:ta=^I:ts=\\E[1$}\\"..., 2048) = 2048
read(3, ":am:es:hs:mi:ms:xn:xo:\\\n\t:co#80:"..., 2048) = 2048
read(3, "13 Oct 1993\n# (vt400: string cap"..., 2048) = 2048
read(3, "?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%"..., 2048) = 2048
read(3, "26~:F5=\\E[28~:\\\n\t:F6=\\E[29~:F7=\\"..., 2048) = 2048
read(3, "dded <rmam>/<smam> based on the "..., 2048) = 2048
read(3, "        CTRL-COMND is Emacs meta"..., 2048) = 2048
read(3, "th.magic.mb.ca> Sept 10 1995\nz34"..., 2048) = 2048
read(3, "E[11~:\\\n\t:k2=\\E[12~:k3=\\E[13~:k4"..., 2048) = 2048
read(3, "dP:DL=\\E[%dM:DO=\\E[%dB:IC=\\E[%d@"..., 2048) = 2048
read(3, ":\\\n\t:km:\\\n\t:kb=^H:ku=\\EOA:kd=\\EO"..., 2048) = 2048
close(3)                                = 0
open("/etc/termcap", O_RDONLY)          = 3
read(3, "######## TERMINAL TYPE DESCRIPTI"..., 2048) = 2048
read(3, "rses suite; it differs from stoc"..., 2048) = 2048
read(3, "or their hardware\n# (notably DEC"..., 2048) = 2048
read(3, " support one attribute without m"..., 2048) = 2048
read(3, "The terminal enquire string <u9>"..., 2048) = 2048
read(3, "w hardware).\n#\n# For the termina"..., 2048) = 2048
read(3, " redistribute freely.\n# There ar"..., 2048) = 2048
read(3, "%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;"..., 2048) = 2048
read(3, "[24m:\\\n\t:tc=klone+sgr:\n\n# For co"..., 2048) = 2048
read(3, ":   Hugh Hansard\n#              "..., 2048) = 2048
read(3, "\\\n\t:li#25:tc=pcansi:\npcansi-33|p"..., 2048) = 2048
read(3, "                           *\n# *"..., 2048) = 2048
read(3, "1%{10}%-%p\'a\'%+%c%e%p1%d%p2%{255"..., 2048) = 2048
read(3, "xxyyzz~~:\\\n\t:ae=\\E(B:al=\\E[L:as="..., 2048) = 2048
read(3, "ion with 43 lines and 132 cols:\\"..., 2048) = 2048
read(3, "H:mb=\\E[5m:\\\n\t:md=\\E[1m:me=\\E[m:"..., 2048) = 2048
read(3, "223s\\224t\\225u\\226v\\227w\\230x\\23"..., 2048) = 2048
read(3, "\\\n\t:AB=\\E[4%p1%dm:AF=\\E[3%p1%dm:"..., 2048) = 2048
read(3, " state (concept at beginning of "..., 2048) = 2048
read(3, "$Op        |  $On    |         |"..., 2048) = 2048
read(3, "=\\E[?7l:RI=\\E[%dC:SA=\\E[?7h:UP=\\"..., 2048) = 2048
read(3, "y (or vt102-nsgr) is probably th"..., 2048) = 2048
read(3, "ys\n# at the top of the keyboard."..., 2048) = 2048
read(3, "o fit entry within 1023 bytes)\n#"..., 2048) = 2048
read(3, "r=\\EM:ta=^I:ue=\\E[24m:up=\\E[A:us"..., 2048) = 2048
read(3, "m:sr=\\EM:st=\\EH:ta=^I:ts=\\E[1$}\\"..., 2048) = 2048
read(3, ":am:es:hs:mi:ms:xn:xo:\\\n\t:co#80:"..., 2048) = 2048
read(3, "13 Oct 1993\n# (vt400: string cap"..., 2048) = 2048
read(3, "?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%"..., 2048) = 2048
read(3, "26~:F5=\\E[28~:\\\n\t:F6=\\E[29~:F7=\\"..., 2048) = 2048
read(3, "dded <rmam>/<smam> based on the "..., 2048) = 2048
read(3, "        CTRL-COMND is Emacs meta"..., 2048) = 2048
read(3, "th.magic.mb.ca> Sept 10 1995\nz34"..., 2048) = 2048
read(3, "E[11~:\\\n\t:k2=\\E[12~:k3=\\E[13~:k4"..., 2048) = 2048
read(3, "dP:DL=\\E[%dM:DO=\\E[%dB:IC=\\E[%d@"..., 2048) = 2048
read(3, ":\\\n\t:km:\\\n\t:kb=^H:ku=\\EOA:kd=\\EO"..., 2048) = 2048
close(3)                                = 0
open("/etc/termcap", O_RDONLY)          = 3
read(3, "######## TERMINAL TYPE DESCRIPTI"..., 2048) = 2048
read(3, "rses suite; it differs from stoc"..., 2048) = 2048
read(3, "or their hardware\n# (notably DEC"..., 2048) = 2048
read(3, " support one attribute without m"..., 2048) = 2048
read(3, "The terminal enquire string <u9>"..., 2048) = 2048
read(3, "w hardware).\n#\n# For the termina"..., 2048) = 2048
read(3, " redistribute freely.\n# There ar"..., 2048) = 2048
read(3, "%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;"..., 2048) = 2048
read(3, "[24m:\\\n\t:tc=klone+sgr:\n\n# For co"..., 2048) = 2048
read(3, ":   Hugh Hansard\n#              "..., 2048) = 2048
read(3, "\\\n\t:li#25:tc=pcansi:\npcansi-33|p"..., 2048) = 2048
read(3, "                           *\n# *"..., 2048) = 2048
read(3, "1%{10}%-%p\'a\'%+%c%e%p1%d%p2%{255"..., 2048) = 2048
read(3, "xxyyzz~~:\\\n\t:ae=\\E(B:al=\\E[L:as="..., 2048) = 2048
read(3, "ion with 43 lines and 132 cols:\\"..., 2048) = 2048
read(3, "H:mb=\\E[5m:\\\n\t:md=\\E[1m:me=\\E[m:"..., 2048) = 2048
read(3, "223s\\224t\\225u\\226v\\227w\\230x\\23"..., 2048) = 2048
read(3, "\\\n\t:AB=\\E[4%p1%dm:AF=\\E[3%p1%dm:"..., 2048) = 2048
read(3, " state (concept at beginning of "..., 2048) = 2048
read(3, "$Op        |  $On    |         |"..., 2048) = 2048
read(3, "=\\E[?7l:RI=\\E[%dC:SA=\\E[?7h:UP=\\"..., 2048) = 2048
read(3, "y (or vt102-nsgr) is probably th"..., 2048) = 2048
read(3, "ys\n# at the top of the keyboard."..., 2048) = 2048
read(3, "o fit entry within 1023 bytes)\n#"..., 2048) = 2048
read(3, "r=\\EM:ta=^I:ue=\\E[24m:up=\\E[A:us"..., 2048) = 2048
read(3, "m:sr=\\EM:st=\\EH:ta=^I:ts=\\E[1$}\\"..., 2048) = 2048
read(3, ":am:es:hs:mi:ms:xn:xo:\\\n\t:co#80:"..., 2048) = 2048
read(3, "13 Oct 1993\n# (vt400: string cap"..., 2048) = 2048
read(3, "?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%"..., 2048) = 2048
                  stat64("/var/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=1952, ...}) = 0
           open("/var/tmp/Ex0000027792", O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600) = 3
 open("README", O_RDONLY)                = 4
                                            fstat64(4, {st_mode=S_IFREG|0644, st_size=8202, ...}) = 0
                     read(4, "$Id:", 4)                      = 4
                                                                lseek(4, 0, SEEK_SET)                   = 0
                           access("README", W_OK)                  = 0
                                                                      fstat64(4, {st_mode=S_IFREG|0644, st_size=8202, ...}) = 0
                                               read(4, "$Id: README,v 1.3 2003/07/12 09:"..., 131072) = 8202
                            read(4, "", 131072)                     = 0
                                                                       fsync(4)                                = 0
                                  close(4)                                = 0
                                                                             --- SIGSEGV (Segmentation fault) @ 0 (0) ---
                                         +++ killed by SIGSEGV +++
Comment 5 Ryan Phillips (RETIRED) gentoo-dev 2004-05-26 16:55:23 UTC
I just built vi with the same cflags as Vince and everything works fine.  I'm under kernel 2.6.6 though.

Portage 2.0.50-r6 (default-x86-2004.0, gcc-3.3.2, glibc-2.3.2-r9, 2.6.6)
=================================================================
System uname: 2.6.6 i686 Intel(R) Pentium(R) III Mobile CPU      1133MHz
Gentoo Base System version 1.4.10
distcc 2.13 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
Autoconf: sys-devel/autoconf-2.58-r1
Automake: sys-devel/automake-1.8.3
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -march=pentium3 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=pentium3 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://lug.mtu.edu/gentoo/"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X apm arts avi berkdb cdr crypt cups encode esd foomaticdb gdbm gif gnome gpm gtk gtk2 imlib java jpeg kde ldap libg++ libwww mad mikmod motif mozilla mpeg mysql ncurses nls oggvorbis opengl oss pam pdflib perl png postgres python qt quicktime readline ruby sdl slang spell ssl svga tcltk tcpd tetex truetype x86 xml2 xmms xv zlib"
Comment 6 Ciaran McCreesh 2004-07-31 07:43:36 UTC
Does this still occur in 2.6.8_rc1 or later?
Comment 7 Ciaran McCreesh 2004-08-01 14:14:13 UTC
Can't reproduce this one with newer kernels. If anyone can trigger it using 2.6.8_rc1 (*not* -mm) or later, please reopen.