Dominique Pellé wrote:

> Hi
>
> Thanks, I can now reproduce the E315 bug too using your
> indications and Vim-7.2.368 on Linux.
>
> I simplified the script a bit to use the 3 files
> (testfile1, testfile2, test.vim) as follows:
>
> $ cat testfile1
> "{{{
>    abc
> "}}}
>
> $ cat testfile2
> "{{{
>    abc
> "}}}
> "{{{
>    def
> "}}}
>
> $ cat test.vim
> set scrolloff=3 foldmethod=marker
> au BufEnter * norm H
> e testfile1
> e testfile2
> exe "norm G"
> bp
>
> $ vim -u NONE -c 'so test.vim'
>
> ... gives
>
> Error detected while processing BufEnter Auto commands for "*":
> E315: ml_get: invalid lnum: 6
> E315: ml_get: invalid lnum: 5
> E315: ml_get: invalid lnum: 4


The script could be simplified a little bit further:

$ cat test.vim
set scrolloff=3 foldmethod=marker
au BufEnter * norm H
e testfile1
e testfile2
bp

$ vim -u NONE -c 'so test.vim'
E315: ml_get: invalid lnum: 6
E315: ml_get: invalid lnum: 5
E315: ml_get: invalid lnum: 4

Putting a breakpoint at the location of E315, I see this stack trace:

Breakpoint 1, ml_get_buf (buf=0x82104c0, lnum=6, will_change=0) at
memline.c:2103
2103                EMSGN(_("E315: ml_get: invalid lnum: %ld"), lnum);
(gdb) bt
#0  ml_get_buf (buf=0x82104c0, lnum=6, will_change=0) at memline.c:2103
#1  0x0810665b in plines_win_nofold (wp=0x820f538, lnum=6) at misc1.c:1732
#2  0x08106735 in plines_win_nofill (wp=0x820f538, lnum=6,
winheight=1) at misc1.c:1713
#3  0x081067a8 in plines_win (wp=0x820f538, lnum=6, winheight=1) at misc1.c:1679
#4  0x081067f2 in plines (lnum=6) at misc1.c:1667
#5  0x0810f8ab in cursor_correct () at move.c:2291
#6  0x0811e782 in nv_scroll (cap=0xbfffde5c) at normal.c:5780
#7  0x08123975 in normal_cmd (oap=0xbfffded0, toplevel=0) at normal.c:1188
#8  0x0809ff4e in exec_normal_cmd (cmd=0x832ce6d "H", remap=0,
silent=0) at ex_docmd.c:9194
#9  0x080a337c in ex_normal (eap=0xbfffe09c) at ex_docmd.c:9093
#10 0x080ab72e in do_one_cmd (cmdlinep=<value optimized out>,
sourcing=<value optimized out>,
    cstack=<value optimized out>, fgetline=0x80bd260 <getnextac>,
cookie=0xbfffe5b0) at ex_docmd.c:2627
#11 0x080a9b88 in do_cmdline (cmdline=0x0, getline=0x80bd260
<getnextac>, cookie=0xbfffe5b0, flags=7)
    at ex_docmd.c:1096
#12 0x080bcd29 in apply_autocmds_group (event=EVENT_BUFENTER,
fname=0x832e440 "/home/pel/bug/testfile1",
    fname_io=<value optimized out>, force=0, group=-3, buf=0x82104c0,
eap=0x0) at fileio.c:9077
#13 0x0805a375 in enter_buffer (buf=0x82104c0) at buffer.c:1425
#14 0x0805ab6b in do_buffer (action=0, start=0, dir=-1, count=1,
forceit=0) at buffer.c:1275
#15 0x0805b88b in goto_buffer (eap=0xbfffe7ac, start=0, dir=-1,
count=1) at buffer.c:695
#16 0x080a7ba8 in ex_bprevious (eap=0xbfffe7ac) at ex_docmd.c:4945
#17 0x080ab72e in do_one_cmd (cmdlinep=<value optimized out>,
sourcing=<value optimized out>,
    cstack=<value optimized out>, fgetline=0x809d480 <getsourceline>,
cookie=0xbfffed08) at ex_docmd.c:2627
#18 0x080a9b88 in do_cmdline (cmdline=0x83266e8 "set scrolloff=3
foldmethod=marker",
    getline=0x809d480 <getsourceline>, cookie=0xbfffed08, flags=7) at
ex_docmd.c:1096
#19 0x0809d9ca in do_source (fname=0x82ab693 "test.vim",
check_other=0, is_vimrc=0) at ex_cmds2.c:3206
#20 0x0809e095 in cmd_source (fname=0x82104c0 "\003", eap=0x0) at
ex_cmds2.c:2811
#21 0x080ab72e in do_one_cmd (cmdlinep=<value optimized out>,
sourcing=<value optimized out>,
    cstack=<value optimized out>, fgetline=0, cookie=0x0) at ex_docmd.c:2627
#22 0x080a9b88 in do_cmdline (cmdline=0xbffff6a8 "so test.vim",
getline=0, cookie=0x0, flags=11) at ex_docmd.c:1096
#23 0x080adfb9 in do_cmdline_cmd (cmd=0xbffff6a8 "so test.vim") at
ex_docmd.c:702
#24 0x080e61eb in exe_commands (argc=3, argv=0xbffff514) at main.c:2732
#25 main (argc=3, argv=0xbffff514) at main.c:887

(gdb) p buf
$12 = (buf_T *) 0x82104c0

(gdb) p curwin->w_buffer
$13 = (buf_T *) 0x82104c0

(gdb) p curwin->w_buffer->b_ml.ml_line_count
$14 = 3

(gdb) p curwin->w_botline
$15 = 7

(gdb) p /x curwin->w_valid
$17 = 0xe4


I think that curwin->w_valid has VALID_BOTLINE bit set
even though w_botline is not valid (it's bigger than the number
of lines in the buffer).

Following change avoids the E315 bug, but it's not
the correct way of fixing the bug yet.

$ hg diff move.c
diff -r 4bac7ed34007 src/move.c
--- a/src/move.c        Thu Feb 18 15:53:29 2010 +0100
+++ b/src/move.c        Sun Feb 21 11:13:01 2010 +0100
@@ -582,7 +582,7 @@
     void
 validate_botline()
 {
-    if (!(curwin->w_valid & VALID_BOTLINE))
+    /*if (!(curwin->w_valid & VALID_BOTLINE))*/
        comp_botline(curwin);
 }


I suppose that w_botline is updated incorrectly
somewhere, without invalidating it, but I don't know
where that would be yet.

-- Dominique

-- 
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui