all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 9948@debbugs.gnu.org
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	[thread overview]
Message-ID: <E1RNIGI-0007Jl-UP@fencepost.gnu.org> (raw)
In-Reply-To: <4EB766E8.5050908@cs.ucla.edu> (message from Paul Eggert on Sun,  06 Nov 2011 21:04:40 -0800)

> 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	other threads:[~2011-11-07  6:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 21:55 bug#9948: valgrind warning: Conditional jump or move depends on uninitialised value(s) in redisplay_window Dan Nicolaescu
2011-11-03 22:17 ` Eli Zaretskii
2011-11-03 23:30   ` Dan Nicolaescu
2011-11-04  9:04     ` Eli Zaretskii
2011-11-04 13:05       ` Dan Nicolaescu
2016-07-11  3:49         ` npostavs
2011-11-07  5:04 ` Paul Eggert
2011-11-07  6:00   ` Eli Zaretskii [this message]
2011-11-07  6:08     ` Paul Eggert
2011-11-07  6:30       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1RNIGI-0007Jl-UP@fencepost.gnu.org \
    --to=eliz@gnu.org \
    --cc=9948@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.