Internal error on Vim 7.2

31 views
Skip to first unread message

Martti Kuparinen

unread,
Mar 2, 2010, 3:41:55 AM3/2/10
to vim...@vim.org
Hi,

I'm the Vim maintainer in NetBSD pkgsrc and I was looking two weird problem reports:

http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=39375
http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=42909

Few minutes ago I tested the first myself with 7.2.367 and I have no problems on
NetBSD/amd64 while on NetBSD/i386 I get the same

E341: Internal error: lalloc(0, )
cannot yank; delete anyway (y/n)?

message as described in both PRs. Any ideas where to start debugging this?

Martti

Bram Moolenaar

unread,
Mar 2, 2010, 7:46:41 AM3/2/10
to Martti Kuparinen, vim...@vim.org

Martti Kuparinen wrote:

I can't reproduc this.

You could compile Vim with debugging symbols, run it in gdb and set a
breakpoint at the error message. Then look at the stack trace.
Going a few frames back should show you where the size is computed
wrong. Most likely it's to do with MAXCOL, as the "$" command uses
that for the desired column position.

--
"Never be afraid to tell the world who you are."
-- Anonymous

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Martti Kuparinen

unread,
Mar 3, 2010, 9:04:59 AM3/3/10
to Bram Moolenaar, vim...@vim.org
I had few minutes to debug this, so far I found this...

# ldd vim
ldd: vim: not dynamically linked
# file vim
vim: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically
linked, for NetBSD 5.99.24, not stripped
# gdb vim

(gdb) break lalloc

Breakpoint 1, lalloc (size=2, message=1) at misc2.c:837
837 if (size == 0)
(gdb) c
Continuing.

Breakpoint 1, lalloc (size=28, message=1) at misc2.c:837
837 if (size == 0)
(gdb) c
Continuing.

Breakpoint 1, lalloc (size=4, message=1) at misc2.c:837
837 if (size == 0)
(gdb) c
Continuing.

Breakpoint 1, lalloc (size=0, message=1) at misc2.c:837
837 if (size == 0)

(gdb) bt
#0 lalloc (size=0, message=1) at misc2.c:837
#1 0x080f5e63 in alloc (size=0) at misc2.c:767
#2 0x08114963 in yank_copy_line (bd=0xbfbfe780, y_idx=0) at ops.c:3162
#3 0x08114301 in op_yank (oap=0xbfbfeaf8, deleting=1, mess=0) at ops.c:2926
#4 0x08112098 in op_delete (oap=0xbfbfeaf8) at ops.c:1725
#5 0x08113c65 in op_change (oap=0xbfbfeaf8) at ops.c:2634
#6 0x08104efe in do_pending_operator (cap=0xbfbfea4c, old_col=2147483647,
gui_yank=0) at normal.c:1953
#7 0x08103a6d in normal_cmd (oap=0xbfbfeaf8, toplevel=1) at normal.c:1214
#8 0x080cfb0c in main_loop (cmdwin=0, noexmode=0) at main.c:1211
#9 0x080cf6f3 in main (argc=2, argv=0xbfbfecac) at main.c:955

(gdb) frame 2
#2 0x08114963 in yank_copy_line (bd=0xbfbfe780, y_idx=0) at ops.c:3162
3162 if ((pnew = alloc(bd->startspaces + bd->endspaces + bd->textlen + 1))
(gdb) p bd->startspaces
$2 = -1
(gdb) p bd->endspaces
$3 = 0
(gdb) p bd->textlen
$4 = 0


What should I try next?

PS. Any interest for a minimalistic VMware Player image of NetBSD/i386 with
checked-out pkgsrc tree and debug build of vim where you can use gdb yourself?

Martti

Lech Lorens

unread,
Mar 3, 2010, 9:23:14 AM3/3/10
to vim...@googlegroups.com
On 3 March 2010 15:04, Martti Kuparinen <martti.k...@iki.fi> wrote:
>
> PS. Any interest for a minimalistic VMware Player image of NetBSD/i386 with
> checked-out pkgsrc tree and debug build of vim where you can use gdb
> yourself?
>
> Martti

Yesterday I tried to install NetBSD under Qemu but the installation hanged
during the boot process...
If you make your image available somewhere, I might try to run it under Qemu.
I'm not promising it will work, however (though I believe it should).

--
Best regards,
Lech Lorens

Martti Kuparinen

unread,
Mar 3, 2010, 12:29:11 PM3/3/10
to vim...@googlegroups.com, Bram Moolenaar, vim...@vim.org
> PS. Any interest for a minimalistic VMware Player image of NetBSD/i386
> with checked-out pkgsrc tree and debug build of vim where you can use
> gdb yourself?

I have VirtualBox 3.1.4 on my home PC so here's a VDI image instead of VMware
VMDK image:

http://kuparinen.org/martti/tmp/netbsd5vim72.xml
http://kuparinen.org/martti/tmp/netbsd5vim72.vdi.bz2 (81 MB)

You have to uncompress the disk image, register it with your VirtualBox and
move the xml file to correct location.

After booting the VM, check the IP address with "ifconfig wm0" so you can SSH
into the host. Next open three SSH sessions and follow the instructions printed
by /etc/motd...

Login: root
Password: root

SSH allows root login...

Martti

Bram Moolenaar

unread,
Mar 3, 2010, 4:01:30 PM3/3/10
to Martti Kuparinen, vim...@vim.org

Martti Kuparinen wrote:

You can get all with: print *bd

> What should I try next?

Apparently something goes wrong in block_prep(), just before calling
yank_copy_line(). If you can put a breakpoint in block_prep() and step
through it to find out why bdp->startspaces ends up being negative, and
textlen zero, that will help a lot. Look out for an overflow somewhere.
Perhaps in line 4966? Actually, knowing the values in oap will help:
print *oap

If these values look wrong, look at the code that sets them: about line
1660 in normal.c

--
Not too long ago, compress was something you did to garbage...

Martti Kuparinen

unread,
Mar 3, 2010, 4:54:41 PM3/3/10
to vim...@googlegroups.com
Bram Moolenaar wrote:

> Apparently something goes wrong in block_prep(), just before calling
> yank_copy_line(). If you can put a breakpoint in block_prep() and step
> through it to find out why bdp->startspaces ends up being negative, and
> textlen zero, that will help a lot. Look out for an overflow somewhere.
> Perhaps in line 4966? Actually, knowing the values in oap will help:
> print *oap

4966 bdp->startspaces = oap->end_vcol - oap->start_vcol + 1;
(gdb) p *oap
$30 = {op_type = 3, regname = 45, motion_type = 0, motion_force = 0,
use_reg_one = 0, inclusive = 1, end_adjusted = 0, start = {lnum = 1,
col = 2, coladd = 0}, end = {lnum = 1, col = 0, coladd = 0},
cursor_start = {lnum = 0, col = 0, coladd = 0}, line_count = 1, empty = 0,
is_VIsual = 1, block_mode = 1, start_vcol = 2, end_vcol = 0,
prev_opcount = 0, prev_count0 = 0}
(gdb) n
4967 if (is_del && oap->op_type != OP_LSHIFT)
(gdb) p bdp->startspaces
$31 = -1
(gdb) n
5018 bdp->end_char_vcols = incr;
(gdb) p incr
$32 = 1
(gdb) n
5020 if (is_del && bdp->startspaces)
(gdb) p is_del
$33 = 0
(gdb) n
5022 bdp->textlen = (int)(pend - pstart);
(gdb) p pend
$34 = (char_u *) 0xbba49ffd " "
(gdb) p pstart
$35 = (char_u *) 0xbba49ffd " "
(gdb) where
#0 block_prep (oap=0xbfbfeae8, bdp=0xbfbfe770, lnum=1, is_del=0) at ops.c:5022
#1 0x08114398 in op_yank (oap=0xbfbfeae8, deleting=1, mess=0) at ops.c:2925
#2 0x08112144 in op_delete (oap=0xbfbfeae8) at ops.c:1725
#3 0x08113d11 in op_change (oap=0xbfbfeae8) at ops.c:2634
#4 0x08104faa in do_pending_operator (cap=0xbfbfea3c, old_col=2147483647,
gui_yank=0) at normal.c:1953
#5 0x08103b19 in normal_cmd (oap=0xbfbfeae8, toplevel=1) at normal.c:1214
#6 0x080cfb88 in main_loop (cmdwin=0, noexmode=0) at main.c:1211
#7 0x080cf76f in main (argc=2, argv=0xbfbfec9c) at main.c:955

> If these values look wrong, look at the code that sets them: about line
> 1660 in normal.c

Why is oap->end_vcol zero? I'll continue tomorrow with this...

Martti Kuparinen

unread,
Mar 4, 2010, 5:57:32 AM3/4/10
to vim...@googlegroups.com
Martti Kuparinen wrote:

> After booting the VM, check the IP address with "ifconfig wm0" so you
> can SSH into the host. Next open three SSH sessions and follow the
> instructions printed by /etc/motd...
>
> Login: root
> Password: root
>
> SSH allows root login...

Here's a VMware Player 3.0.1 tested image, use "ifconfig -a" to see the IP
address configured by DHCP.

http://kuparinen.org/martti/tmp/netbsd5vim72.tar.bz2

Martti

Lech Lorens

unread,
Mar 6, 2010, 6:58:34 AM3/6/10
to vim...@googlegroups.com, Martti Kuparinen

The attached patch fixes the problem.

Additionally, I indented the comment in memline.c as its wrong
indentation always misleads me to think that the function ends just
before the comment.

--
Cheers,
Lech

bad-pointer-arithmetics.patch

Bram Moolenaar

unread,
Mar 6, 2010, 8:39:03 AM3/6/10
to Lech Lorens, vim...@googlegroups.com, Martti Kuparinen

Lech Lorens wrote:

Thanks!

I must say I'm really happy to get patches from you and others. Perhaps
finally the todo list will be getting shorter?

--
A real patriot is the fellow who gets a parking ticket and rejoices
that the system works.

Martti Kuparinen

unread,
Mar 6, 2010, 11:56:22 AM3/6/10
to Bram Moolenaar, Lech Lorens, vim...@googlegroups.com
I hereby confirm that the patch fixes my problems on NetBSD/i386.

Bram, please provide an "official" patch so I can update our package...

Martti

Reply all
Reply to author
Forward
0 new messages