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

Re: segv related to virtualedit in 6.0al

Expand Messages
  • Matt Dunford
    ... I can reproduce on Mandrake 8. Make sure you compile vim with debugging on. The backtraces produce more info that way. I compile it like this, for
    Message 1 of 8 , Jun 29, 2001
    • 0 Attachment
      * Mark Waggoner <waggoner@...> [010628 19:41]:
      >
      > vim -u NONE junk
      > itest
      > again
      > and again<ESC>
      > 1G
      > :set ve=block
      > <C-V>G$y
      >
      >
      > Results in:
      > Program received signal SIGSEGV, Segmentation fault.
      > 0x8076fc2 in getvvcol ()
      > (gdb) where
      > #0 0x8076fc2 in getvvcol ()
      > #1 0x80e01a8 in do_pending_operator ()
      > #2 0x80df899 in normal_cmd ()
      > #3 0x80bb8cb in main_loop ()
      > #4 0x80bb638 in main ()
      > #5 0x404079ab in __libc_start_main () at ../sysdeps/generic/libc-start.c:122
      > (gdb)

      I can reproduce on Mandrake 8. Make sure you compile vim with debugging
      on. The backtraces produce more info that way. I compile it like
      this, for example:
      %> CFLAGS='-g -pipe' ./configure --with-features=huge --without-x --disable-gui && make

      Here's my backtrace:

      (gdb) bt
      #0 0x4009ad11 in kill () from /lib/libc.so.6
      #1 0x080f2a2e in may_core_dump () at os_unix.c:2365
      #2 0x080f29e3 in mch_exit (r=1) at os_unix.c:2342
      #3 0x080a8084 in getout (exitval=1) at main.c:1960
      #4 0x080c62f2 in preserve_exit () at misc1.c:6144
      #5 0x080f1a97 in deathtrap (sigarg=11) at os_unix.c:811
      #6 0x4009ab68 in killpg () from /lib/libc.so.6
      #7 0x080d46c1 in do_pending_operator (cap=0xbffff230,
      old_col=2147483647, gui_yank=0)
      at normal.c:1426
      #8 0x080d3bdc in normal_cmd (oap=0xbffff2a0, toplevel=1) at
      normal.c:1034
      #9 0x080a7ee4 in main_loop (cmdwin=0) at main.c:1875
      #10 0x080a7c15 in main (argc=0, argv=0xbffff48c) at main.c:1732
      #11 0x4008a0de in __libc_start_main () from /lib/libc.so.6

      I don't know how to fix this, but it looks like old_col is set to an
      outrageously high value in do_pending_operator() and ml_get_cursor()
      returns an invalid pointer on line 1216 of charset.c.
    • Zdenek Sekera
      ... Confirmed also on IRIX: Vim: Caught deadly signal BUS Vim: preserving files... Vim: Finished. Bus error(coredump)
      Message 2 of 8 , Jun 29, 2001
      • 0 Attachment
        Matt Dunford wrote:
        >
        > * Mark Waggoner <waggoner@...> [010628 19:41]:
        > >
        > > vim -u NONE junk
        > > itest
        > > again
        > > and again<ESC>
        > > 1G
        > > :set ve=block
        > > <C-V>G$y
        ...
        > I can reproduce on Mandrake 8.

        Confirmed also on IRIX:

        Vim: Caught deadly signal BUS
        Vim: preserving files...
        Vim: Finished.
        Bus error(coredump)

        ---Zdenek
      • Yasuhiro Matsumoto
        Hello ... if typing $, curwin- w_cursor.col will be MAXCOL so it must no use ml_get_cursor(). and when curwin- w_cursor.col is MAXCOL, coladd shoud be 0. This
        Message 3 of 8 , Jun 29, 2001
        • 0 Attachment
          Hello

          Mark Waggoner wrote:
          >vim -u NONE junk
          >itest
          >again
          >and again<ESC>
          >1G
          >:set ve=block
          ><C-V>G$y

          if typing $, curwin->w_cursor.col will be MAXCOL
          so it must no use ml_get_cursor().
          and when curwin->w_cursor.col is MAXCOL, coladd shoud be 0.

          This is a patch.
          Please check this.

          *** src.org\charset.c Mon Jun 25 02:28:51 2001
          --- src\charset.c Fri Jun 29 09:34:58 2001
          ***************
          *** 1213,1221 ****
          getvcol(wp, pos, &col, NULL, NULL);

          /* Adjust for multiwide char */
          ! ptr = ml_get_cursor();
          ! if (*ptr != TAB && *ptr != NUL && ptr2cells(ptr) > 1)
          ! pos->coladd = 0;

          col += pos->coladd;
          if (start != NULL)
          --- 1213,1224 ----
          getvcol(wp, pos, &col, NULL, NULL);

          /* Adjust for multiwide char */
          ! if (wp->w_curswant != MAXCOL)
          ! {
          ! ptr = ml_get_cursor();
          ! if (*ptr != TAB && *ptr != NUL && ptr2cells(ptr) > 1)
          ! pos->coladd = 0;
          ! }

          col += pos->coladd;
          if (start != NULL)

          -
          Yasuhiro Matsumoto
        • Bram Moolenaar
          ... Hmm, there must be something wrong before getting here. curwin- w_cursor.col should never be MAXCOL. w_curswant may be MAXCOL though. -- Everyone has a
          Message 4 of 8 , Jun 29, 2001
          • 0 Attachment
            Yasuhiro Matsumoto wrote:

            > Mark Waggoner wrote:
            > >vim -u NONE junk
            > >itest
            > >again
            > >and again<ESC>
            > >1G
            > >:set ve=block
            > ><C-V>G$y
            >
            > if typing $, curwin->w_cursor.col will be MAXCOL
            > so it must no use ml_get_cursor().
            > and when curwin->w_cursor.col is MAXCOL, coladd shoud be 0.

            Hmm, there must be something wrong before getting here. curwin->w_cursor.col
            should never be MAXCOL. w_curswant may be MAXCOL though.

            --
            Everyone has a photographic memory. Some don't have film.

            /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
            ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
            \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
          • Chase Tingley
            ... Actually, he s right -- do_pending_operator() (normal.c:1426) is setting curwin- w_cursor.col = MAXCOL and then repeatedly calling getvvcol() in order to
            Message 5 of 8 , Jun 29, 2001
            • 0 Attachment
              On Fri, 29 Jun 2001, Bram Moolenaar wrote:

              > > if typing $, curwin->w_cursor.col will be MAXCOL
              > > so it must no use ml_get_cursor().
              > > and when curwin->w_cursor.col is MAXCOL, coladd shoud be 0.
              >
              > Hmm, there must be something wrong before getting here. curwin->w_cursor.col
              > should never be MAXCOL. w_curswant may be MAXCOL though.

              Actually, he's right -- do_pending_operator() (normal.c:1426) is setting
              curwin->w_cursor.col = MAXCOL and then repeatedly calling getvvcol() in
              order to "test" and find out the biggest vcol in the block.

              This is sort of bad behavior.

              ct
            • Chase Tingley
              ... I have a slight issue with this, because I don t think it fixes the underlying bug -- it only works here because w_curswant happens to be set to MAXCOL.
              Message 6 of 8 , Jun 29, 2001
              • 0 Attachment
                On Fri, 29 Jun 2001, Yasuhiro Matsumoto wrote:

                > This is a patch.
                > Please check this.
                >
                > *** src.org\charset.c Mon Jun 25 02:28:51 2001
                > --- src\charset.c Fri Jun 29 09:34:58 2001
                > ***************
                > *** 1213,1221 ****
                > getvcol(wp, pos, &col, NULL, NULL);
                >
                > /* Adjust for multiwide char */
                > ! ptr = ml_get_cursor();
                > ! if (*ptr != TAB && *ptr != NUL && ptr2cells(ptr) > 1)
                > ! pos->coladd = 0;
                >
                > col += pos->coladd;
                > if (start != NULL)
                > --- 1213,1224 ----
                > getvcol(wp, pos, &col, NULL, NULL);
                >
                > /* Adjust for multiwide char */
                > ! if (wp->w_curswant != MAXCOL)
                > ! {
                > ! ptr = ml_get_cursor();
                > ! if (*ptr != TAB && *ptr != NUL && ptr2cells(ptr) > 1)
                > ! pos->coladd = 0;
                > ! }
                >
                > col += pos->coladd;
                > if (start != NULL)
                >

                I have a slight issue with this, because I don't think it fixes the
                underlying bug -- it only works here because w_curswant happens to be set
                to MAXCOL. It seems dangerous to rely on an association between pos and
                wp->w_curswant, as there's no guarantee that in general they will be
                related.

                A slightly different attempt along the same lines (also changing
                ml_get_cursor to ml_get_pos):

                --- charset.c.orig Sun Jun 24 13:28:51 2001
                +++ charset.c Fri Jun 29 11:19:03 2001
                @@ -1212,10 +1212,13 @@
                /* For virtual mode, only want one value */
                getvcol(wp, pos, &col, NULL, NULL);

                + if (pos->col != MAXCOL)
                + {
                /* Adjust for multiwide char */
                - ptr = ml_get_cursor();
                + ptr = ml_get_pos(pos);
                if (*ptr != TAB && *ptr != NUL && ptr2cells(ptr) > 1)
                pos->coladd = 0;
                + }

                col += pos->coladd;
                if (start != NULL)
              • Bram Moolenaar
                ... Yes, it assumes that getvvcol() can handle a position past the end of the line. Hmm, mostly that s OK, since it s supposed to get the width of each
                Message 7 of 8 , Jun 29, 2001
                • 0 Attachment
                  Chase Tingley wrote:

                  > On Fri, 29 Jun 2001, Bram Moolenaar wrote:
                  >
                  > > > if typing $, curwin->w_cursor.col will be MAXCOL
                  > > > so it must no use ml_get_cursor().
                  > > > and when curwin->w_cursor.col is MAXCOL, coladd shoud be 0.
                  > >
                  > > Hmm, there must be something wrong before getting here.
                  > > curwin->w_cursor.col should never be MAXCOL. w_curswant may be MAXCOL
                  > > though.
                  >
                  > Actually, he's right -- do_pending_operator() (normal.c:1426) is setting
                  > curwin->w_cursor.col = MAXCOL and then repeatedly calling getvvcol() in
                  > order to "test" and find out the biggest vcol in the block.
                  >
                  > This is sort of bad behavior.

                  Yes, it assumes that getvvcol() can handle a position past the end of the
                  line. Hmm, mostly that's OK, since it's supposed to get the width of each
                  character and stop at the NUL. But in this case we simply add the column,
                  which doesn't work.

                  Making it always find the end of the line takes extra time, and it's only
                  needed when "coladd" is non-zero. In this situation ("$" was used) that's
                  actually impossible.

                  How about this replacement in getvvcol():

                  if (virtual_active())
                  {
                  /* For virtual mode, only want one value */
                  getvcol(wp, pos, &col, NULL, NULL);

                  if (pos->coladd > 0)
                  {
                  /* Adjust for multiwide char */
                  ptr = ml_get(pos->lnum);
                  if (pos->col <= STRLEN(ptr))
                  {
                  ptr += pos->col;
                  if (*ptr != TAB && *ptr != NUL && ptr2cells(ptr) > 1)
                  pos->coladd = 0;
                  }
                  col += pos->coladd;
                  }


                  It's still not right though: "$" moves the cursor to just after the end of the
                  line and then "y" includes an extra space which isn't there. I think the
                  place in do_pending_operator() that handles "$" doesn't compensate for
                  'selection', like it's done just above the handling of MAXCOL.

                  --
                  Those who live by the sword get shot by those who don't.

                  /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
                  ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
                  \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
                Your message has been successfully submitted and would be delivered to recipients shortly.