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

[patch] fixed illegal memory access introduced by vim-7.4.19

Expand Messages
  • Dominique PellĂ©
    Hi When running test32 with vim-7.4.22, I see this valgrind error: ==17589== Memcheck, a memory error detector ==17589== Copyright (C) 2002-2011, and GNU
    Message 1 of 3 , Sep 6, 2013
    • 0 Attachment
      Hi

      When running test32 with vim-7.4.22, I see this valgrind error:

      ==17589== Memcheck, a memory error detector
      ==17589== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
      ==17589== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
      ==17589== Command: ../vim -u unix.vim -U NONE -c set\ maxmem=256
      --noplugin -s dotest.in test32.in
      ==17589== Parent PID: 16711
      ==17589==
      ==17589== Invalid read of size 1
      ==17589== at 0x4BCE96: utf_head_off (mbyte.c:3434)
      ==17589== by 0x424339: ins_complete (edit.c:5191)
      ==17589== by 0x42A7C1: edit (edit.c:1410)
      ==17589== by 0x4C10F7: invoke_edit (normal.c:9232)
      ==17589== by 0x4C3721: nv_edit (normal.c:9205)
      ==17589== by 0x4C9014: normal_cmd (normal.c:1200)
      ==17589== by 0x576AE9: main_loop (main.c:1329)
      ==17589== by 0x579C1B: main (main.c:1020)
      ==17589== Address 0xc3daa4f is 1 bytes before a block of size 8 alloc'd
      ==17589== at 0x4C2B3F8: malloc (in
      /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==17589== by 0x4B5DE6: lalloc (misc2.c:929)
      ==17589== by 0x4B5E8B: alloc_check (misc2.c:862)
      ==17589== by 0x4A975E: ins_str (misc1.c:2347)
      ==17589== by 0x42703D: insertchar (edit.c:6043)
      ==17589== by 0x4279DB: insert_special (edit.c:5806)
      ==17589== by 0x42AC3C: edit (edit.c:1491)
      ==17589== by 0x4C10F7: invoke_edit (normal.c:9232)
      ==17589== by 0x4C3721: nv_edit (normal.c:9205)
      ==17589== by 0x4C9014: normal_cmd (normal.c:1200)
      ==17589== by 0x576AE9: main_loop (main.c:1329)
      ==17589== by 0x579C1B: main (main.c:1020)


      Line edit.c:5191 was recently modified in this patch:

      changeset: 5332:d5eb32dc231c
      tag: v7-4-019
      user: Bram Moolenaar <bram@...>
      date: Thu Sep 05 13:50:53 2013 +0200
      files: src/edit.c src/version.c
      description:
      updated for version 7.4.019
      Problem: MS-Windows: File name completion doesn't work properly with
      Chinese characters. (Yue Wu)
      Solution: Take care of multi-byte characters when looking for the start of
      the file name. (Ken Takata)

      $ hg annotate edit.c:

      5184 vimboss 7: else if (ctrl_x_mode == CTRL_X_FILES)
      5185 vimboss 7: {
      5186 bram 5332: char_u *p = line + startcol;
      5187 bram 5332:
      5188 bram 5332: /* Go back to just before the first filename
      character. */
      5189 bram 5332: mb_ptr_back(line, p);
      5190 bram 5332: while (vim_isfilec(PTR2CHAR(p)) && p >= line)
      !5191 bram 5332: mb_ptr_back(line, p);
      5192 bram 5332: startcol = p - line;
      5193 bram 5332:
      5194 vimboss 449: compl_col += ++startcol;
      5195 vimboss 449: compl_length = (int)curs_col - startcol;
      5196 vimboss 449: compl_pattern = addstar(line + compl_col, compl_length,
      5197 vimboss 449: EXPAND_FILES);
      5198 vimboss 449: if (compl_pattern == NULL)
      5199 vimboss 7: return FAIL;
      5200 vimboss 7: }

      Attached patch fixed it but please verify it.

      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ken Takata
      Hi Dominique, ... Sorry, it s my patch. ... Seems good. Your patch works fine for multi-byte characters. Regards, Ken Takata -- -- You received this message
      Message 2 of 3 , Sep 7, 2013
      • 0 Attachment
        Hi Dominique,

        2013/09/07 Sat 15:52:02 UTC+9 Dominique Pelle wrote:
        > Line edit.c:5191 was recently modified in this patch:
        >
        > changeset: 5332:d5eb32dc231c
        > tag: v7-4-019
        > user: Bram Moolenaar <bram@...>
        > date: Thu Sep 05 13:50:53 2013 +0200
        > files: src/edit.c src/version.c
        > description:
        > updated for version 7.4.019
        > Problem: MS-Windows: File name completion doesn't work properly with
        > Chinese characters. (Yue Wu)
        > Solution: Take care of multi-byte characters when looking for the start of
        > the file name. (Ken Takata)

        Sorry, it's my patch.

        > Attached patch fixed it but please verify it.

        Seems good. Your patch works fine for multi-byte characters.

        Regards,
        Ken Takata

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

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Bram Moolenaar
        ... Thanks for the patch! Theoretically it might still be invalid to have a pointer just before a string. I never encountered a machine with that problem, but
        Message 3 of 3 , Sep 8, 2013
        • 0 Attachment
          Dominique wrote:

          > When running test32 with vim-7.4.22, I see this valgrind error:
          >
          > ==17589== Memcheck, a memory error detector
          > ==17589== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
          > ==17589== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
          > ==17589== Command: ../vim -u unix.vim -U NONE -c set\ maxmem=256
          > --noplugin -s dotest.in test32.in
          > ==17589== Parent PID: 16711
          > ==17589==
          > ==17589== Invalid read of size 1
          > ==17589== at 0x4BCE96: utf_head_off (mbyte.c:3434)
          > ==17589== by 0x424339: ins_complete (edit.c:5191)
          > ==17589== by 0x42A7C1: edit (edit.c:1410)
          > ==17589== by 0x4C10F7: invoke_edit (normal.c:9232)
          > ==17589== by 0x4C3721: nv_edit (normal.c:9205)
          > ==17589== by 0x4C9014: normal_cmd (normal.c:1200)
          > ==17589== by 0x576AE9: main_loop (main.c:1329)
          > ==17589== by 0x579C1B: main (main.c:1020)
          > ==17589== Address 0xc3daa4f is 1 bytes before a block of size 8 alloc'd
          > ==17589== at 0x4C2B3F8: malloc (in
          > /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
          > ==17589== by 0x4B5DE6: lalloc (misc2.c:929)
          > ==17589== by 0x4B5E8B: alloc_check (misc2.c:862)
          > ==17589== by 0x4A975E: ins_str (misc1.c:2347)
          > ==17589== by 0x42703D: insertchar (edit.c:6043)
          > ==17589== by 0x4279DB: insert_special (edit.c:5806)
          > ==17589== by 0x42AC3C: edit (edit.c:1491)
          > ==17589== by 0x4C10F7: invoke_edit (normal.c:9232)
          > ==17589== by 0x4C3721: nv_edit (normal.c:9205)
          > ==17589== by 0x4C9014: normal_cmd (normal.c:1200)
          > ==17589== by 0x576AE9: main_loop (main.c:1329)
          > ==17589== by 0x579C1B: main (main.c:1020)
          >
          >
          > Line edit.c:5191 was recently modified in this patch:
          >
          > changeset: 5332:d5eb32dc231c
          > tag: v7-4-019
          > user: Bram Moolenaar <bram@...>
          > date: Thu Sep 05 13:50:53 2013 +0200
          > files: src/edit.c src/version.c
          > description:
          > updated for version 7.4.019
          > Problem: MS-Windows: File name completion doesn't work properly with
          > Chinese characters. (Yue Wu)
          > Solution: Take care of multi-byte characters when looking for the start of
          > the file name. (Ken Takata)
          >
          > $ hg annotate edit.c:
          >
          > 5184 vimboss 7: else if (ctrl_x_mode == CTRL_X_FILES)
          > 5185 vimboss 7: {
          > 5186 bram 5332: char_u *p = line + startcol;
          > 5187 bram 5332:
          > 5188 bram 5332: /* Go back to just before the first filename
          > character. */
          > 5189 bram 5332: mb_ptr_back(line, p);
          > 5190 bram 5332: while (vim_isfilec(PTR2CHAR(p)) && p >= line)
          > !5191 bram 5332: mb_ptr_back(line, p);
          > 5192 bram 5332: startcol = p - line;
          > 5193 bram 5332:
          > 5194 vimboss 449: compl_col += ++startcol;
          > 5195 vimboss 449: compl_length = (int)curs_col - startcol;
          > 5196 vimboss 449: compl_pattern = addstar(line + compl_col, compl_length,
          > 5197 vimboss 449: EXPAND_FILES);
          > 5198 vimboss 449: if (compl_pattern == NULL)
          > 5199 vimboss 7: return FAIL;
          > 5200 vimboss 7: }
          >
          > Attached patch fixed it but please verify it.

          Thanks for the patch!

          Theoretically it might still be invalid to have a pointer just before a
          string. I never encountered a machine with that problem, but it's nicer
          to have starcol not become negative and then increment it. Thus I'll
          change it slightly:

          mb_ptr_back(line, p);
          while (p > line && vim_isfilec(PTR2CHAR(p)))
          mb_ptr_back(line, p);
          startcol = (int)(p - line) + 1;
          if (p == line && vim_isfilec(PTR2CHAR(p)))
          startcol = 0;

          compl_col += startcol;


          --
          hundred-and-one symptoms of being an internet addict:
          187. You promise yourself that you'll only stay online for another
          15 minutes...at least once every hour.

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.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

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.