Dominique Pellé wrote:
Hi

I see the following Valgrind error with Gvim-7.2.402 (GTK2 GUI on Linux).

==12686== Conditional jump or move depends on uninitialised value(s)
==12686==    at 0x53A5E0: screen_comp_differs (screen.c:6294)
==12686==    by 0x53AB30: screen_puts_len (screen.c:6456)
==12686==    by 0x53A177: win_redr_custom (screen.c:6179)
==12686==    by 0x539B88: redraw_custom_statusline (screen.c:5948)
==12686==    by 0x53969F: win_redr_status (screen.c:5810)
==12686==    by 0x52EEC3: update_screen (screen.c:532)
==12686==    by 0x4AA976: main_loop (main.c:1128)
==12686==    by 0x4AA610: main (main.c:955)
(and more errors after that)

Steps to reproduce:

1) Install the 'taglist' plugin available at:

   http://www.vim.org/scripts/script.php?script_id=273

2) Create a minimalistic ~/.vimrc file containing only one line:

   filetype plugin on

3) Start gvim with valgrind:

   $ valgrind --log-file=vg.log vim -f -g

4) Maximize the gvim window by pressing maximize button of
   the Window Manager

5) Type Ex command:

   :TlistToggle

6) Observe errors in Valgrind log file 'vg.log' (access to uninitialized
   memory)

Code where error happens:

  6285     static int
  6286 screen_comp_differs(off, u8cc)
  6287     int     off;
  6288     int     *u8cc;
  6289 {
  6290     int     i;
  6291
  6292     for (i = 0; i < Screen_mco; ++i)
  6293     {
!!6294         if (ScreenLinesC[i][off] != (u8char_T)u8cc[i])
  6295             return TRUE;
  6296         if (u8cc[i] == 0)
  6297             break;
  6298     }
  6299     return FALSE;
  6300 }

- 'i' and 'off' are initialized.
- ScreenLinesC[i] is also initialized.
- but ScreenLinesC[i][off] is _not_ initialized.

I did a bisection with "hg bisect" between 7.2.100 (good, no bug)
and 7.2.402 (bad):

 7.2.100 -> good
 7.2.109 -> good
 7.2.114 -> good
 7.2.116 -> good
 7.2.117 -> good
 7.2.118 -> good
 7.2.119 -> bad
 7.2.139 -> bad
 7.2.178 -> bad
 7.2.258 -> bad
 7.2.402 -> bad

The patch which introduces the bug is:

 Patch 7.2.119
 Problem:    Status line is redrawn too often.
 Solution:   Check ScreeenLinesUC[] properly. (Yukihiro Nakadaira)
 Files:      src/screen.c

Patch seemed to be only an optimization. But since it breaks
something, we should revert it back I think, unless someone
knows how to fix it?  I verified that no error happens when
reverting it (as in attached patch).

It seems that ScreenLinesC is not cleared when allocating screen buffer
with screenalloc(TRUE) and it is not assigned any value for an ASCII
character.  Maybe ScreenLinesC is not expected to be an valid value when
ScreenLinesUC == 0?

And also the current code does not work for when "c" is ASCII character
and "u8cc" contains composing character.

I can't reproduce valgrind error surely.  But I think the following
patch will fix the bug.

--- a/src/screen.c
+++ b/src/screen.c
@@ -6461,8 +6461,8 @@
                    && c == 0x8e
                    && ScreenLines2[off] != ptr[1])
                || (enc_utf8
-                   && (ScreenLinesUC[off] != (u8char_T)(c >= 0x80 ? u8c : 0)
-                       || screen_comp_differs(off, u8cc)))
+                   && (ScreenLinesUC[off] != (u8char_T)(c < 0x80 && u8cc[0] == 
0 ? 0 : u8c)
+                       || (ScreenLinesUC[off] != 0 && screen_comp_differs(off, 
u8cc))))
 #endif
                || ScreenAttrs[off] != attr
                || exmode_active;


--
Yukihiro Nakadaira - yukihiro.nakada...@gmail.com

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

To unsubscribe from this group, send email to vim_dev+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Raspunde prin e-mail lui