Dasn wrote:
> Hello guys.
>
> I recently caught an E38 (Null argument).
>
> gvim -u NONE "+so trap_e38.vim"
>
> (the trap_e38.vim is in attachment)
>
> :version
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 13 2010 09:32:48)
> MS-Windows 32-bit GUI version
> Included patches: 1-394
> Compiled by administra...@bla
> Big version with GUI. Features included (+) or not (-):
I can reproduce it with at least Vim-7.2.394 (and Vim-7.2.245)
in the terminal:
$ vim -u NONE -c ':so trap_e38.vim'
... gives E38 error. But I can only reproduce it if the number
of lines is <= 28. So you may need to add ":set lines=25" for
example in trap_e38.vim" to reproduce it.
It happens here:
#3 0x0814c526 in vim_regexec_both (line=0x0, col=0, tm=0x820b3c8)
at regexp.c:3426
#4 0x0814c3fa in vim_regexec_multi (rmp=0x820b300, win=0x976ff20,
buf=0x9770d50, lnum=0, col=0, tm=0x820b3c8) at regexp.c:3369
#5 0x0815cb49 in next_search_hl (win=0x976ff20, shl=0x820b300, lnum=0,
mincol=0) at screen.c:6782
#6 0x08156a07 in win_line (wp=0x976ff20, lnum=0, startrow=0, endrow=1,
nochange=1) at screen.c:3167
#7 0x0815462e in win_update (wp=0x976ff20) at screen.c:1774
#8 0x0815274d in update_screen (type=40) at screen.c:524
#9 0x080ddef8 in main_loop (cmdwin=0, noexmode=0) at main.c:1128
#10 0x080ddb8b in main (argc=5, argv=0xbfb22174) at main.c:955
regexp.c:
3409 if (REG_MULTI)
3410 {
3411 prog = reg_mmatch->regprog;
3412 line = reg_getline((linenr_T)0);
3413 reg_startpos = reg_mmatch->startpos;
3414 reg_endpos = reg_mmatch->endpos;
3415 }
3416 else
3417 {
3418 prog = reg_match->regprog;
3419 reg_startp = reg_match->startp;
3420 reg_endp = reg_match->endp;
3421 }
3422
3423 /* Be paranoid... */
3424 if (prog == NULL || line == NULL)
3425 {
3426 EMSG(_(e_null));
3427 goto theend;
3428 }
(gdb)
#3 0x0814c526 in vim_regexec_both (line=0x0, col=0, tm=0x820b3c8) at regexp.c:3
426
(gdb) p prog
$1 = (regprog_T *) 0x976ee68
(gdb) p line
$2 = (char_u *) 0x0
(gdb)
Breakpoint 1 at 0x814c4e6: file regexp.c, line 3419.
(gdb) p reg_match
$3 = (regmatch_T *) 0x0
(gdb) p line
$4 = (char_u *) 0x0
(gdb) p reg_firstlnum
$5 = 0
E38 happens at line 3426 because line is NULL.
line was set to NULL at line 3412 since reg_getline(0)
returns NULL at line 3264 (reg_firstlnum being 0 and lnum being 0):
3257 static char_u *
3258 reg_getline(lnum)
3259 linenr_T lnum;
3260 {
3261 /* when looking behind for a match/no-match lnum is negative. But we
3262 * can't go before line 1 */
3263 if (reg_firstlnum + lnum < 1)
3264 return NULL;
reg_firstlnum was set to 0 at at line vim_regex.c:3358:
3343 vim_regexec_multi(rmp, win, buf, lnum, col, tm)
3344 regmmatch_T *rmp;
3345 win_T *win; /* window in which to search or NULL */
3346 buf_T *buf; /* buffer in which to search */
3347 linenr_T lnum; /* nr of line to start looking for match */
3348 colnr_T col; /* column to start looking for match */
3349 proftime_T *tm; /* timeout limit or NULL */
3350 {
3351 long r;
3352 buf_T *save_curbuf = curbuf;
3353
3354 reg_match = NULL;
3355 reg_mmatch = rmp;
3356 reg_buf = buf;
3357 reg_win = win;
3358 reg_firstlnum = lnum;
#3 0x08158d75 in vim_regexec_multi (rmp=0x821f480, win=0x9c42500,
buf=0x9c43360, lnum=0, col=0, tm=0x821f548) at
regexp.c:3358
#4 0x0816a297 in next_search_hl (win=0x9c42500, shl=0x821f480,
lnum=0, mincol=0) at screen.c:6781
#5 0x08163af6 in win_line (wp=0x9c42500, lnum=0, startrow=0,
endrow=1, nochange=1) at screen.c:3167
#6 0x081610ca in win_update (wp=0x9c42500) at screen.c:1774
#7 0x0815f1e9 in update_screen (type=40) at screen.c:524
#8 0x080e53ef in main_loop (cmdwin=0, noexmode=0) at main.c:1128
#9 0x080e5082 in main (argc=5, argv=0xbfa77254) at main.c:955
lnum is set to 0 in wind_update() at line screen.c:1496.
1496 lnum = wp->w_topline; /* first line shown in window */
w_topline was set to 0 at move.c:2197
2194 #ifdef FEAT_FOLDING
2195 if (!hasFolding(topline, &curwin->w_topline, NULL))
2196 #endif
2197 curwin->w_topline = topline;
topeline was set to 0 at move.c:2157:
2146 loff.lnum = boff.lnum = curwin->w_cursor.lnum;
2147 #ifdef FEAT_FOLDING
2148 (void)hasFolding(loff.lnum, &loff.lnum, &boff.lnum);
2149 #endif
2150 #ifdef FEAT_DIFF
2151 used = plines_nofill(loff.lnum);
2152 loff.fill = 0;
2153 boff.fill = 0;
2154 #else
2155 used = plines(loff.lnum);
2156 #endif
2157 topline = loff.lnum
2157 topline = loff.lnum;
loff.lnum was set to 0 at line move.c:2146 from
curwin->w_cursor.lnum.
So the position of the cursor is wrong. I think
curwin->w_cursor.lnum is 0 because it's set
in popupmnu.c:643 to 0:
643 curwin->w_cursor.lnum = 0;
If I replace this line with...
643 curwin->w_cursor.lnum = 1;
... then E38 no longer happens, but I have no idea
whether this fix is correct!
$ hg diff popupmnu.c
diff -r aab202d244b6 src/popupmnu.c
--- a/src/popupmnu.c Wed Mar 10 17:16:12 2010 +0100
+++ b/src/popupmnu.c Sun Mar 14 10:50:53 2010 +0100
@@ -640,7 +640,7 @@
curbuf->b_changed = 0;
curbuf->b_p_ma = FALSE;
- curwin->w_cursor.lnum = 0;
+ curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
if (curwin != curwin_save && win_valid(curwin_save))
-- Dominique
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php