Caught E38 Null argument

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Caught E38 Null argument

Dasn

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 Administrator@BLA
Big version with GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset  
+cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info  
+comments
+cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path  
+find_in_path
+float +folding -footer -gettext -hangul_input +iconv/dyn +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds  
+localmap
+menu +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn
+multi_lang -mzscheme +netbeans_intg -ole -osfiletype +path_extra -perl
-postscript +printer -profile -python +quickfix +reltime +rightleft -ruby
+scrollbind +signs +smartindent -sniff +startuptime +statusline  
-sun_workshop
+syntax +tag_binary +tag_old_static -tag_any_white -tcl -tgetent  
-termresponse
+textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
-xfontset -xim -xterm_save -xpm_w32
    system vimrc file: "$VIM\vimrc"
      user vimrc file: "$HOME\_vimrc"
  2nd user vimrc file: "$VIM\_vimrc"
       user exrc file: "$HOME\_exrc"
   2nd user exrc file: "$VIM\_exrc"
   system gvimrc file: "$VIM\gvimrc"
     user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$VIM\_gvimrc"
     system menu file: "$VIMRUNTIME\menu.vim"
Compilation: gcc -Iproto -DWIN32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  
-DHAVE_PATHDEF -DFEAT_BIG -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG  
-DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME  
-DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -w -march=i686 -Wall -g -fstack-check
Linking: gcc -Iproto -DWIN32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  
-DHAVE_PATHDEF -DFEAT_BIG -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG  
-DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME  
-DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -w -march=i686 -Wall -g -fstack-check  
-mwindows -o gvimd.exe -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32  
-lcomctl32 -lversion -lwsock32 -lole32 -luuid

--
Dasn

--
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

trap_e38.vim (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Caught E38 Null argument

Dominique Pellé
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 Administrator@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
Reply | Threaded
Open this post in threaded view
|

Re: Caught E38 Null argument

Lech Lorens
On 14-Mar-2010 Dominique Pellé <[hidden email]> wrote:

>
> 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))
Your modification fixes more than just this problem. Accidentally, I was
recently investigating a problem with scrolling the preview window when
the pop-up menu is visible. This can be reproduced as follows:
- build C tags for Vim sources,
- open ex_docmd.c in Gvim, go to line 1689,
- set 'cot' to "menu,preview", set 'number',
- insert the following line:
        if (ea.
- without leaving the insert mode invoke omnicompletion by pressing <C-o>,
- move the mouse pointer so that it hovers over the preview window and
  use the mouse scroll wheel to first scroll the window's contents up
  (by rotating the scroll wheel DOWN).

At this point the preview window will have scrolled by 1 line in the
opposite direction than intended and will show line number 0, containing
a copy of line 1. What is more, if you scroll the mouse wheel up, you
will be able to make the window display lines with negative numbers.

Your patch prevents Gvim from behaving this way. My modifications fix
the problem too but they do not fix the problem reported by Dasn.
However, I am still attaching a patch for Bram to consider whether it is
worthwhile to include the changes just for the sake of safety.

The patch also includes a change to fold.c - I removed a redundant
check.

--
Cheers,
Lech

--
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

preview-scroll.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Caught E38 Null argument

Dominique Pellé
Lech Lorens wrote:

> On 14-Mar-2010 Dominique Pellé <[hidden email]> wrote:
>> $ 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))
>
> Your modification fixes more than just this problem. Accidentally, I was
> recently investigating a problem with scrolling the preview window when
> the pop-up menu is visible. This can be reproduced as follows:
> - build C tags for Vim sources,
> - open ex_docmd.c in Gvim, go to line 1689,
> - set 'cot' to "menu,preview", set 'number',
> - insert the following line:
>        if (ea.
> - without leaving the insert mode invoke omnicompletion by pressing <C-o>,
> - move the mouse pointer so that it hovers over the preview window and
>  use the mouse scroll wheel to first scroll the window's contents up
>  (by rotating the scroll wheel DOWN).
>
> At this point the preview window will have scrolled by 1 line in the
> opposite direction than intended and will show line number 0, containing
> a copy of line 1. What is more, if you scroll the mouse wheel up, you
> will be able to make the window display lines with negative numbers.
>
> Your patch prevents Gvim from behaving this way.

Just to confirm that I can reproduce the negative line number bug
you describe (with gvim GTK2) and that setting "curwin->w_cursor.lnum"
to 1 instead of 0 at popupmnu.c:643 does indeed fix it and also fixes
the E38 error described by Dan. It looks promising.

-- 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
Reply | Threaded
Open this post in threaded view
|

Re: Caught E38 Null argument

Bram Moolenaar
In reply to this post by Lech Lorens

Lech Lorens wrote:

> On 14-Mar-2010 Dominique Pellé <[hidden email]> wrote:
> >
> > 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))
>
> Your modification fixes more than just this problem. Accidentally, I was
> recently investigating a problem with scrolling the preview window when
> the pop-up menu is visible. This can be reproduced as follows:
> - build C tags for Vim sources,
> - open ex_docmd.c in Gvim, go to line 1689,
> - set 'cot' to "menu,preview", set 'number',
> - insert the following line:
> if (ea.
> - without leaving the insert mode invoke omnicompletion by pressing <C-o>,
> - move the mouse pointer so that it hovers over the preview window and
>   use the mouse scroll wheel to first scroll the window's contents up
>   (by rotating the scroll wheel DOWN).
>
> At this point the preview window will have scrolled by 1 line in the
> opposite direction than intended and will show line number 0, containing
> a copy of line 1. What is more, if you scroll the mouse wheel up, you
> will be able to make the window display lines with negative numbers.
>
> Your patch prevents Gvim from behaving this way. My modifications fix
> the problem too but they do not fix the problem reported by Dasn.
> However, I am still attaching a patch for Bram to consider whether it is
> worthwhile to include the changes just for the sake of safety.
>
> The patch also includes a change to fold.c - I removed a redundant
> check.

I'll include that.  And thanks for checking Dominique's patch.

--
CRONE:  Who sent you?
ARTHUR: The Knights Who Say Ni!
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no shrubberies here.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- 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    ///

--
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