Hi John!

On Di, 25 Jan 2011, John Beckett wrote:

> Hoss wrote:
> > $ find . -mindepth 1 -maxdepth 1 -name '*.pm' | xargs sh -c
> > '/usr/ local/bin/vim -p "$@" </dev/tty'
> >
> > The find command has 60 hits. Now, if I just run this
> > command, it works fine, and I get 10 tabpages. I want each in
> > their own tabpage, so I put this in my .vimrc file
> >
> > set tpm=60
> >
> > With that change, when I run the command, I get the following:
> >
> > Vim: Caught deadly signal SEGV
> > Vim: Finished
> > Segmentation fault
> 
> Please try a simpler test. Does the following lead to a crash?

I can reproduce this. The problem here is a custom 'tabline' setting and 
this results in a crash in the build_stl_str_hl() function. I have a 
rather complicated tabline-setting, that I picked up in vim-use I guess. 
I never need it though (and in fact tend to forget about it ;))

Here is a possible fix, that at least prevents the crash, but also 
prevents drawing the statusline and tabline label. I must admit, I 
haven't had time to investigate the build_stl_str_hl function in detail, 
so I don't know the proper fix:
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3465,9 +3465,9 @@
        /*
         * Handle up to the next '%' or the end.
         */
-       while (*s != NUL && *s != '%' && p + 1 < out + outlen)
+       while (*s != NUL && *s != '%' && p + 1 < out + outlen && *p != NUL)
            *p++ = *s++;
-       if (*s == NUL || p + 1 >= out + outlen)
+       if (*s == NUL || p + 1 >= out + outlen || *p == NUL)
            break;

        /*
diff --git a/src/screen.c b/src/screen.c
--- a/src/screen.c
+++ b/src/screen.c
@@ -6429,7 +6429,7 @@
     int                n;
     int                len;
     int                fillchar;
-    char_u     buf[MAXPATHL];
+    char_u     buf[MAXPATHL] = "";
     char_u     *stl;
     char_u     *p;
     struct     stl_hlrec hltab[STL_MAX_ITEM];


Attached is:
valgrind.log when running the vim -N -i NONE --cmd 'set tpm=65' -p 
/tmp/vim-crash/* (a directory containing about 60 files)
tabline.vim My custom tabline setting

regards,
Christian

-- 
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
==26523== Memcheck, a memory error detector
==26523== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==26523== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for 
copyright info
==26523== Command: ./vim -N -i NONE --cmd set\ tpm=65 -p /tmp/vim-crash/1 
/tmp/vim-crash/10 /tmp/vim-crash/11 /tmp/vim-crash/12 /tmp/vim-crash/13 
/tmp/vim-crash/14 /tmp/vim-crash/15 /tmp/vim-crash/16 /tmp/vim-crash/17 
/tmp/vim-crash/18 /tmp/vim-crash/19 /tmp/vim-crash/2 /tmp/vim-crash/20 
/tmp/vim-crash/21 /tmp/vim-crash/22 /tmp/vim-crash/23 /tmp/vim-crash/24 
/tmp/vim-crash/25 /tmp/vim-crash/26 /tmp/vim-crash/27 /tmp/vim-crash/28 
/tmp/vim-crash/29 /tmp/vim-crash/3 /tmp/vim-crash/30 /tmp/vim-crash/31 
/tmp/vim-crash/32 /tmp/vim-crash/33 /tmp/vim-crash/34 /tmp/vim-crash/35 
/tmp/vim-crash/36 /tmp/vim-crash/37 /tmp/vim-crash/38 /tmp/vim-crash/39 
/tmp/vim-crash/4 /tmp/vim-crash/40 /tmp/vim-crash/41 /tmp/vim-crash/42 
/tmp/vim-crash/43 /tmp/vim-crash/44 /tmp/vim-crash/45 /tmp/vim-crash/46 
/tmp/vim-crash/47 /tmp/vim-crash/48 /tmp/vim-crash/49 /tmp/vim-crash/5 
/tmp/vim-crash/50 /tmp/vim-crash/51 /tmp/vim-crash/52 /tmp/vim-crash/53 
/tmp/vim-crash/54 /tmp/vim-crash/55 /tmp/vim-crash/56 /tmp/vim-crash/57 
/tmp/vim-crash/58 /tmp/vim-crash/59 /tmp/vim-crash/6 /tmp/vim-crash/60 
/tmp/vim-crash/7 /tmp/vim-crash/8 /tmp/vim-crash/9
==26523== Parent PID: 26177
==26523== 
==26523== Conditional jump or move depends on uninitialised value(s)
==26523==    at 0x8057B1F: build_stl_str_hl (buffer.c:3470)
==26523==    by 0x816A878: win_redr_custom (screen.c:6519)
==26523==    by 0x816F4E0: draw_tabline (screen.c:9701)
==26523==    by 0x8160525: update_screen (screen.c:465)
==26523==    by 0x80E53B6: main_loop (main.c:1161)
==26523==    by 0x80E5008: main (main.c:961)
==26523==  Uninitialised value was created by a stack allocation
==26523==    at 0x816A60B: win_redr_custom (screen.c:6422)
==26523== 
==26523== Conditional jump or move depends on uninitialised value(s)
==26523==    at 0x8057B1F: build_stl_str_hl (buffer.c:3470)
==26523==    by 0x816A878: win_redr_custom (screen.c:6519)
==26523==    by 0x816A40F: redraw_custom_statusline (screen.c:6314)
==26523==    by 0x8169F77: win_redr_status (screen.c:6176)
==26523==    by 0x8160626: update_screen (screen.c:539)
==26523==    by 0x80E53B6: main_loop (main.c:1161)
==26523==    by 0x80E5008: main (main.c:961)
==26523==  Uninitialised value was created by a stack allocation
==26523==    at 0x816A60B: win_redr_custom (screen.c:6422)
==26523== 
==26523== Conditional jump or move depends on uninitialised value(s)
==26523==    at 0x8057B1F: build_stl_str_hl (buffer.c:3470)
==26523==    by 0x816A878: win_redr_custom (screen.c:6519)
==26523==    by 0x816A40F: redraw_custom_statusline (screen.c:6314)
==26523==    by 0x816FBB4: showruler (screen.c:9936)
==26523==    by 0x80E547A: main_loop (main.c:1193)
==26523==    by 0x80E5008: main (main.c:961)
==26523==  Uninitialised value was created by a stack allocation
==26523==    at 0x816A60B: win_redr_custom (screen.c:6422)
==26523== 
==26523== 
==26523== HEAP SUMMARY:
==26523==     in use at exit: 1,310,818 bytes in 21,329 blocks
==26523==   total heap usage: 167,804 allocs, 146,475 frees, 33,254,609 bytes 
allocated
==26523== 
==26523== LEAK SUMMARY:
==26523==    definitely lost: 40 bytes in 1 blocks
==26523==    indirectly lost: 120 bytes in 10 blocks
==26523==      possibly lost: 190,650 bytes in 5,088 blocks
==26523==    still reachable: 1,120,008 bytes in 16,230 blocks
==26523==         suppressed: 0 bytes in 0 blocks
==26523== Rerun with --leak-check=full to see details of leaked memory
==26523== 
==26523== For counts of detected and suppressed errors, rerun with: -v
==26523== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 118 from 9)
    function! MyTabLine()
      let s = ''
      for i in range(tabpagenr('$'))
        " select the highlighting
        if i + 1 == tabpagenr()
          let s .= '%#TabLineSel#'
        else
          let s .= '%#TabLine#'
        endif

    "    " set the tab page number (for mouse clicks)
        let s .= '%' . (i + 1) . 'T'

        " the label is made by MyTabLabel()
        let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
      endfor

      " after the last tab fill with TabLineFill and reset tab page nr
      let s .= '%#TabLineFill#%T'

      " right-align the label to close the current tab page
      if tabpagenr('$') > 1
        let s .= '%=%#TabLine#%999Xclose'
      endif

      return s
    endfunction

Raspunde prin e-mail lui