Subject: Re: bin/1326: vi editing bug
To: None <neil@demon.net>
From: Neil J. McRae <neil@demon.net>
List: netbsd-bugs
Date: 08/11/1995 01:34:01
Incidentally this happens on Amiga, Sparc and i386 ports.
Myself and Michael van Elst had a closer look and it appears that the bug
also happens on the same vi compiled for SunOS, so I'm relieved that it's
not a NetSBD bug, but would like a fix nonetheless :-) [thanks Michael]

> 
> >Description:
> 	In vi when editing a line with:
>     set ts=4
>     set wrapmargin=5
>     set wrapscan
>     When inserting text near the end of a line, what looks like to be a 
>     memory leak or data going past bounds, The line is corrupt with lots of
>    ^@'s Trying an ^[:e! to get the file back segfaults vi:
> 
> [no idea if this is any use]
> 
> Program terminated with signal 11, Segmentation fault.
> #0  0x40cf244 in ?? ()
> (gdb) bt
> #0  0x40cf244 in ?? ()
> #1  0x40c3248 in ?? ()
> #2  0x40bdf94 in ?? ()
> #3  0x40c1dfc in ?? ()
> #4  0x5504 in ?? ()
> #5  0x3cb4 in ?? ()
> #6  0x17a00 in ?? ()
> #7  0x137a0 in ?? ()
> #8  0x11674 in ?? ()
> #9  0x3443c in ?? ()
> #10 0x26664 in ?? ()
> #11 0x32678 in ?? ()
> #12 0x37c88 in ?? ()
> #13 0x711c in ?? ()
> >How-To-Repeat:
> 
This might be more useful:
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.so...done.
Reading symbols from /usr/lib/libcurses.so.2.1...done.
Reading symbols from /usr/lib/libtermlib.so.0.0...done.
Reading symbols from /usr/lib/libutil.so.3.1...done.
Reading symbols from /usr/lib/libc.so.12.3...done.
#0  0x40ef244 in malloc ()
(gdb) bt
#0  0x40ef244 in malloc ()
#1  0x40e3248 in __bt_open ()
#2  0x40ddf94 in __rec_open ()
#3  0x40e1dfc in dbopen ()
#4  0x71a0 in log_init (sp=0x6e800, ep=0x74280) at log.c:129
#5  0x4cb0 in file_init (sp=0x6e800, frp=0x6f0c0, rcv_name=0x0, force=1024)
   at exf.c:248
#6  0x25e34 in ex_edit (sp=0x6e800, ep=0x74100, cmdp=0xf7ffee60)
    at /usr/src/usr.bin/vi/common/../ex/ex_edit.c:118
#7  0x1e890 in ex_cmd (sp=0x6e800, ep=0x74100, cmd=0x706c3 "", cmdlen=0, 
    needsep=0) at /usr/src/usr.bin/vi/common/../ex/ex.c:1349
#8  0x1b4fc in ex_icmd (sp=0x6e800, ep=0x74100, cmd=0x706c0 ":e!", len=3, 
    needsep=0) at /usr/src/usr.bin/vi/common/../ex/ex.c:255
#9  0x55588 in svi_ex_run (sp=0x6e800, ep=0x74100, rp=0xf7fff118)
    at /usr/src/usr.bin/vi/common/../svi/svi_ex.c:173
#10 0x3dfe8 in v_ex (sp=0x6e800, ep=0x74100, vp=0xf7fff0e8)
    at /usr/src/usr.bin/vi/common/../vi/v_ex.c:109
#11 0x522c4 in vi (sp=0x6e800, ep=0x74100)
    at /usr/src/usr.bin/vi/common/../vi/vi.c:200
#12 0x5cf20 in svi_screen_edit (sp=0x6e800, ep=0x74100)
    at /usr/src/usr.bin/vi/common/../svi/svi_screen.c:225
#13 0x9b78 in main (argc=1, argv=0xf7fff7a8) at main.c:435



> Install vi current, Use the settings mentioned above
> Edit a file with a line like this:
>        Exec    "elm"         exec rsh axe "exec /usr/X11R6/bin/xterm -fg skyblue -bg black -T Mail -n Mail -e /usr/local/bin/elm &" & </dev/ull >/dev/null 
> 
> In this example try and insert this after the "/usr/X11R6/bin/xterm" part,
> -display NetBSD:0 and the problem should happen, then do ^[:e! and vi will 
> seg fault.
> 
> >Fix:
> A workaround for this was to add it in another part of the line...
> 

Regards,
Neil

-- 
Neil J. McRae.                                       Demon Internet
neil@demon.net