bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9948: valgrind warning: Conditional jump or move depends on uninitia


From: Eli Zaretskii
Subject: bug#9948: valgrind warning: Conditional jump or move depends on uninitialised value(s) in redisplay_window
Date: Mon, 07 Nov 2011 01:00:50 -0500

> Date: Sun, 06 Nov 2011 21:04:40 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> --track-origins=yes should help, but in the meantime, valgrind's
> bug report doesn't necessarily mean that no code ever set scrolling_up.
> 
> It could be that scrolling_up was set this way:
> 
>       scrolling_up = PT > margin_pos;
> 
> but that margin_pos wasn't properly initialized.  For example, suppose
> margin_pos was set this way:
> 
>           margin_pos = IT_CHARPOS (it1);
> 
> This initialization would not be correct if IT_CHARPOS (it1) referenced
> an uninitialized variable.

IT_CHARPOS is defined as follows:

  #define CHARPOS(POS)          (POS).charpos
  #define IT_CHARPOS(IT)        CHARPOS ((IT).current.pos)

And margin_pos is computed as follows:

      EMACS_INT margin_pos = CHARPOS (startp);  <<<<<<<<<<<<<<
      int scrolling_up;
      Lisp_Object aggressive;

      /* If there is a scroll margin at the top of the window, find
         its character position.  */
      if (margin
          /* Cannot call start_display if startp is not in the
             accessible region of the buffer.  This can happen when we
             have just switched to a different buffer and/or changed
             its restriction.  In that case, startp is initialized to
             the character position 1 (BEG) because we did not yet
             have chance to display the buffer even once.  */
          && BEGV <= CHARPOS (startp) && CHARPOS (startp) <= ZV)
        {
          struct it it1;
          void *it1data = NULL;

          SAVE_IT (it1, it, it1data);
          start_display (&it1, w, startp);
          move_it_vertically (&it1, margin);
          margin_pos = IT_CHARPOS (it1);  <<<<<<<<<<<<<<<<<<
          RESTORE_IT (&it, &it, it1data);
        }
      scrolling_up = PT > margin_pos;
      aggressive =
        scrolling_up
        ? BVAR (current_buffer, scroll_up_aggressively)
        : BVAR (current_buffer, scroll_down_aggressively);

Both `startp' and `it1' have a valid CHARPOS, the former by virtue of
this (near the beginning of the function):

  SET_TEXT_POS_FROM_MARKER (startp, w->start);

and the latter by virtue of the start_display call above, which
initializes `it1's character position to `startp'.

Again, I don't see how any of this could involve an uninitialized
variable.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]