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

Re: gvim crash when using UTF-8 locale and paste text from Windows clipboard

Expand Messages
  • Bram Moolenaar
    ... I m glad you were able pin it down this far. That helps a lot. ... I first thought msg_buf could be too small, but you have the same problem with
    Message 1 of 10 , Jul 29 12:15 PM
    • 0 Attachment
      Rainux wrote:

      > Thanks for your hint, use this breakpoint I did a source-level trace
      > and found a strange thing.

      I'm glad you were able pin it down this far. That helps a lot.

      > The sources I used is full Unix sources, with patch 1-85 applied,
      > compiled by gcc in Cygwin (follow Tony's Compiling HowTo).
      >
      > The correct description of the "bug" is follow:
      > When yank or put lines to/from Vim's register(It's independent of
      > Windows clipboard.), if lines more than 2(or bigger?), Vim will
      > display a message such as "8 lines yanked" or "10 more lines". When
      > using zh_CN.UTF-8 locale, Vim will try to display the localized
      > string of the message, the localized yank message will be OK, but
      > try to display the localized put message will cause Vim crash.
      >
      > The yank message is print by ops.c:2871, and the put message is print by
      > misc1.c:3028.
      >
      > ops.c:2871
      > smsg((char_u *)_("%ld lines yanked"), yanklines);
      > // ^ This line display the localized yank message.
      >
      > misc1.c:3028
      > sprintf((char *)msg_buf, _("%ld more lines"), pn);
      > // ^ This line try to format the localized put message but
      > // crash in wscanf().
      > else
      > sprintf((char *)msg_buf, _("%ld fewer lines"), pn);
      >
      > The conversation with gdb:

      I first thought "msg_buf" could be too small, but you have the same
      problem with smsg(), thus that's not the case.

      There must be a problem in gettext(), which is what _() translates into.
      I'm afraid I can't do anything for that. This is the libintl.dll
      library. You could try getting another version of libintl.dll. Are you
      using the one in the Vim distribution?

      You could split up the code to make sure the crash is inside
      gettext(). Change:

      sprintf((char *)msg_buf, _("%ld more lines"), pn);

      To:
      {
      char *ts = _("%ld more lines");
      sprintf((char *)msg_buf, ts, pn);
      }

      If it now crashes in sprintf() then it's a different problem. But from
      your description it should crash in _().

      > Program received signal SIGSEGV, Segmentation fault.
      > 0x77c12a16 in wscanf () from /cygdrive/c/WINDOWS/system32/msvcrt.dll

      I guess it might have something to do with this msvcrt.dll being
      incompatible with the libintl.dll. Try using the libintl.dll that comes
      with cygwin.

      --
      BLACK KNIGHT: None shall pass.
      ARTHUR: I have no quarrel with you, brave Sir knight, but I must cross
      this bridge.
      BLACK KNIGHT: Then you shall die.
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
    • Bram Moolenaar
      ... The problem may be that there is a % character in the second byte of one of the Chinese double-byte characters. sprintf() then may see the wrong
      Message 2 of 10 , Sep 22, 2005
      • 0 Attachment
        Rainux wrote:

        > I'm sorry for some personal reason I've left some days.
        >
        > > {
        > > char *ts =3D _("%ld more lines");
        > > sprintf((char *)msg_buf, ts, pn);
        > > }
        > >
        > > If it now crashes in sprintf() then it's a different problem. But from
        > > your description it should crash in _().
        >
        > I did this, and it crash in sprintf(), seems the problem is in msvcrt.dll.
        >
        > I use Borland C++ 5.5.1 for Win32 compile Vim just now(previously I
        > use Cygwin's gcc), and found the new gvim.exe's import table don't
        > have msvcrt.dll. And, this build of gvim never crashes in zh_CN.UTF-8.
        > So I think the problem should in msvcrt.dll(Bram use MSVC compile Vim,
        > so the "official build" rely on msvcrt.dll).

        The problem may be that there is a % character in the second byte of one
        of the Chinese double-byte characters. sprintf() then may see the wrong
        arguments.

        Another possibility is that msg_buf is too small. I made it longer a
        short while ago. Currently it's 480 bytes. In Vim 6.3 the value was
        80. Patch 6.3.072 changed it to 240. If you are still using 80 then
        this is probably the cause of the trouble.

        --
        "Hegel was right when he said that we learn from history that man can
        never learn anything from history." (George Bernard Shaw)

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      • Bram Moolenaar
        Rainux - ... I plan to switch to the free compiler that MS distributes. But I need to make sure there are no legal problems and find a way to debug the
        Message 3 of 10 , Nov 23, 2005
        • 0 Attachment
          Rainux -

          > Hi Bram, recently I use MSVC 6.0 to compile Vim, and found Vim 6.4
          > will not crash when try to display some UTF-8 encoded Chinese message.
          > Both GCC 3.4.4 in Cygwin and MSVC 5.0 (you use it compile the
          > "official build", don't you?) compiled Vim 6.4 will crash on this
          > case.
          >
          > But Vim 7.0aa already fixed this "bug" (I've tested above version
          > 7.0149), use GCC to compile is OK. And, Vim 7 can correctly hand the
          > Chinese file name on zh_CN.UTF-8 locale now. (Vim 6.4 can't)
          >
          > So, I want to suggest you use the recent version of MSVC to compile
          > the "official build" if possible, thanks.

          I plan to switch to the free compiler that MS distributes. But I need
          to make sure there are no legal problems and find a way to debug the
          resulting program.

          - Bram

          --
          "Hit any key to continue" it said, but nothing happened after F sharp.

          /// Bram Moolenaar -- Bram@... -- 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://www.ICCF.nl ///
        • Rainux
          The free Visual C++ Toolkit 2003 do not contain platform SDK, therefor, you should get the newer .lib and .h files another way ;) I ve used Visual C++ 2003
          Message 4 of 10 , Nov 23, 2005
          • 0 Attachment
            The free Visual C++ Toolkit 2003 do not contain platform SDK,
            therefor, you should get the newer .lib and .h files another way ;)

            I've used Visual C++ 2003 (the compiler and the one in the Visual C++
            Toolkit 2003 is just the same) to compile Vim for some days, and it
            seems work fine.

            Gdb can be used as debugger in Win32 too.

            2005/11/23, Bram Moolenaar <Bram@...>:
            >
            > I plan to switch to the free compiler that MS distributes. But I need
            > to make sure there are no legal problems and find a way to debug the
            > resulting program.
            >
            > - Bram
            >
            > --
            > "Hit any key to continue" it said, but nothing happened after F sharp.
            >
            > /// Bram Moolenaar -- Bram@... -- 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://www.ICCF.nl ///
            >


            --
            Goddess light my path!
          Your message has been successfully submitted and would be delivered to recipients shortly.