Loading ...
Sorry, an error occurred while loading the content.

54408Re: vim 7.2 compiles fine on MSYS but it doesn't execute

Expand Messages
  • Dominique Pellé
    Jun 7, 2009
    • 0 Attachment
      Cesar Romani wrote:

      > 1675                if ((error_msg = tgetent_error(tbuf, term)) == NULL)
      > (gdb) p term
      > $11 = (char_u *) 0xa0158c0 "msys"
      > (gdb) n
      > 1677                    tp = tstrbuf;
      > (gdb) p term
      > $12 = (char_u *) 0x5b455c3d <Address 0x5b455c3d out of bounds>


      1/ OK, so the corruption happens in in tgetent_error(), most likely
      in line 2158 but it might be worth putting a breaking point at line
      term.c:2158 and print 'term' variable before & after executing
      line term.c:2158 to confirm that corruption happens there.

      2151 static char_u *
      2152 tgetent_error(tbuf, term)
      2153 char_u *tbuf;
      2154 char_u *term;
      2155 {
      2156 int i;
      2157
      2158 i = TGETENT(tbuf, term);
      2159 if (i < 0 /* -1 is always an error */
      2160 # ifdef TGETENT_ZERO_ERR
      2161 || i == 0 /* sometimes zero is also an error */
      2162 # endif
      2163 )


      2/ Most likely not enough memory is allocated for tbuf, first
      parameter of tgetent(). Size of buffer is defined in vim.h as follows:

      1348 #if defined(AMIGA) || defined(__linux__) || defined(__QNX__) ||
      defined(__CYGWIN32__) || defined(_AIX)
      1349 # define TBUFSZ 2048 /* buffer size for termcap entry
      */
      1350 #else
      1351 # define TBUFSZ 1024 /* buffer size for termcap entry */
      1352 #endif


      I suspect that on your system (mingw), it's using 1024 instead
      of 2048. If so, the attached patch might fix it. It adds
      "defined(__MINGW32__)" (__MINGW32__ is already used
      in several places in Vim's code):

      1348 #if defined(AMIGA) || defined(__linux__) || defined(__QNX__) ||
      defined(_AIX) \
      1349 || defined(__CYGWIN32__) || defined(__MINGW32__)
      1350 # define TBUFSZ 2048 /* buffer size for termcap entry
      */
      1351 #else
      1352 # define TBUFSZ 1024 /* buffer size for termcap entry */
      1353 #endif


      2/ I also see that some implementations accept NULL as first
      argument of tgetent() and in which case buffer is internally
      dynamically allocated (hence more secure, but not as portable):

      See:
      http://www.gnu.org/software/termutils/manual/termcap-1.3/html_node/termcap_4.html

      quote:

      If you are using the GNU version of termcap, you can alternatively
      ask tgetent to allocate enough space. Pass a null pointer for buffer,
      and tgetent itself allocates the storage using malloc. There is no
      way to get the address that was allocated, and you shouldn't try
      to free the storage.

      So if attached patch does not suffice, it might be worth trying to
      replace tbuf with, i.e. try replacing lines term.c:1675:

      if ((error_msg = tgetent_error(tbuf, term)) == NULL)

      into...

      if ((error_msg = tgetent_error(NULL, term)) == NULL)

      Regards
      -- Dominique

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 15 messages in this topic