From unknown Fri Aug 15 15:32:09 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#8227 <8227@debbugs.gnu.org> To: bug#8227 <8227@debbugs.gnu.org> Subject: Status: possibly uninitialized variables in update_window_fringes Reply-To: bug#8227 <8227@debbugs.gnu.org> Date: Fri, 15 Aug 2025 22:32:09 +0000 retitle 8227 possibly uninitialized variables in update_window_fringes reassign 8227 emacs submitter 8227 Paul Eggert severity 8227 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 10 18:45:35 2011 Received: (at submit) by debbugs.gnu.org; 10 Mar 2011 23:45:35 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PxpXy-0007K5-VT for submit@debbugs.gnu.org; Thu, 10 Mar 2011 18:45:35 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PxpXx-0007Ju-5P for submit@debbugs.gnu.org; Thu, 10 Mar 2011 18:45:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PxpXr-0003eQ-Cx for submit@debbugs.gnu.org; Thu, 10 Mar 2011 18:45:28 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:56758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PxpXr-0003eC-5U for submit@debbugs.gnu.org; Thu, 10 Mar 2011 18:45:27 -0500 Received: from [140.186.70.92] (port=57097 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PxpXp-00029j-7Y for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 18:45:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PxpXn-0003da-5Z for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 18:45:24 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:34829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PxpXm-0003d2-T9 for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2011 18:45:23 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 02D3439E80F8; Thu, 10 Mar 2011 15:45:20 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8GZ+vsoY788W; Thu, 10 Mar 2011 15:45:19 -0800 (PST) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 7187F39E80DF; Thu, 10 Mar 2011 15:45:19 -0800 (PST) Message-ID: <4D79628F.3030106@cs.ucla.edu> Date: Thu, 10 Mar 2011 15:45:19 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: possibly uninitialized variables in update_window_fringes Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: YAMAMOTO Mitsuharu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) Severity: minor I found this problem by compiling Emacs with GCC's -Wuninitialized flag. The following code in the Emacs trunk src/fringe.c's update_window_fringes function might be using uninitialized variables: int top_row_ends_at_zv_p, bot_row_ends_at_zv_p; ... if (top_ind_rn >= 0) { ... top_row_ends_at_zv_p = row->ends_at_zv_p; } ... for (y = w->vscroll, rn = 0; y < yb && rn < nrows; y += row->height, rn++) { ... if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0) ... else if (row->left_user_fringe_bitmap != NO_FRINGE_BITMAP) ... else if ((!row->reversed_p && row->truncated_on_left_p) || (row->reversed_p && row->truncated_on_right_p)) ... else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) { left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) ? LEFT_FRINGE (1, Qtop_bottom, top_row_ends_at_zv_p) : LEFT_FRINGE (2, Qtop, 0)); ... } The last assignment uses top_row_ends_at_zv_p, but it's not clear from the previous tests that top_row_ends_at_zv_p must be initialized. There is a similar issue with bot_row_ends_at_zv_p. I'm filing a bug report so that someone who is more expert in this code can take a look at it. In the meantime, I plan to work around the problem by initializing the two local variables to 0, with a FIXME explaining the situation: this shouldn't introduce a bug, because at worst it will replace undefined behavior with defined behavior. I'm CC'ing this to YAMAMOTO Mitsuharu, who committed the code in question. From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 10 20:31:39 2011 Received: (at 8227) by debbugs.gnu.org; 11 Mar 2011 01:31:40 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PxrCd-0002p5-Ev for submit@debbugs.gnu.org; Thu, 10 Mar 2011 20:31:39 -0500 Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PxrCa-0002oo-J5 for 8227@debbugs.gnu.org; Thu, 10 Mar 2011 20:31:38 -0500 Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id D89A5C055D; Fri, 11 Mar 2011 10:31:27 +0900 (JST) Date: Fri, 11 Mar 2011 10:31:27 +0900 Message-ID: From: YAMAMOTO Mitsuharu To: Paul Eggert Subject: Re: possibly uninitialized variables in update_window_fringes In-Reply-To: <4D79628F.3030106@cs.ucla.edu> References: <4D79628F.3030106@cs.ucla.edu> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) Organization: Faculty of Science, Chiba University MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 8227 Cc: 8227@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) >>>>> On Thu, 10 Mar 2011 15:45:19 -0800, Paul Eggert said: > I found this problem by compiling Emacs with GCC's -Wuninitialized flag. > The following code in the Emacs trunk src/fringe.c's > update_window_fringes function might be using uninitialized > variables: > int top_row_ends_at_zv_p, bot_row_ends_at_zv_p; > ... > if (top_ind_rn >= 0) > { > ... > top_row_ends_at_zv_p = row->ends_at_zv_p; > } > ... > for (y = w->vscroll, rn = 0; > y < yb && rn < nrows; > y += row->height, rn++) > { > ... > if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0) > ... > else if (row->left_user_fringe_bitmap != NO_FRINGE_BITMAP) > ... > else if ((!row->reversed_p && row->truncated_on_left_p) > || (row->reversed_p && row->truncated_on_right_p)) > ... > else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) > { > left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) > ? LEFT_FRINGE (1, Qtop_bottom, top_row_ends_at_zv_p) > : LEFT_FRINGE (2, Qtop, 0)); > ... > } > The last assignment uses top_row_ends_at_zv_p, but it's not clear > from the previous tests that top_row_ends_at_zv_p must be initialized. > There is a similar issue with bot_row_ends_at_zv_p. No problem. top_ind_rn is set to a non-negative value whenever row->indicate_bob_p is set. for (y = w->vscroll, rn = 0; y < yb && rn < nrows; y += row->height, ++rn) { ... if (!row->mode_line_p) { if (top_ind_rn < 0 && row->visible_height > 0) { if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)) && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) row->indicate_bob_p = !NILP (boundary_top); else row->indicate_top_line_p = !NILP (arrow_top); top_ind_rn = rn; } YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 11 01:25:32 2011 Received: (at 8227-done) by debbugs.gnu.org; 11 Mar 2011 06:25:33 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pxvn2-0001ag-AV for submit@debbugs.gnu.org; Fri, 11 Mar 2011 01:25:32 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pxvmz-0001aQ-Jh for 8227-done@debbugs.gnu.org; Fri, 11 Mar 2011 01:25:30 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3CEFD39E80F9; Thu, 10 Mar 2011 22:25:23 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YFV2GYqb7VqV; Thu, 10 Mar 2011 22:25:22 -0800 (PST) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id CAE9039E80DB; Thu, 10 Mar 2011 22:25:22 -0800 (PST) Message-ID: <4D79C052.5080305@cs.ucla.edu> Date: Thu, 10 Mar 2011 22:25:22 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: YAMAMOTO Mitsuharu Subject: Re: possibly uninitialized variables in update_window_fringes References: <4D79628F.3030106@cs.ucla.edu> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 8227-done Cc: 8227-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) On 03/10/2011 05:31 PM, YAMAMOTO Mitsuharu wrote: > No problem. top_ind_rn is set to a non-negative value whenever > row->indicate_bob_p is set. Thanks for explaining that. I plan to add the following comment to the code, just before the declarations of top_row_ends_at_zv_p and bot_row_ends_at_zv_p: /* top_ind_rn is set to a nonnegative value whenver row->indicate_bob_p is set, so it's OK that top_row_ends_at_zv_p is not initialized here. Similarly for bot_ind_rn, row->indicate_eob_p and bot_row_ends_at_zv_p. */ From unknown Fri Aug 15 15:32:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 08 Apr 2011 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator