GNU bug report logs - #51075
29.0.50; Uninitialised variable warning in src/term.c

Previous Next

Package: emacs;

Reported by: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Date: Thu, 7 Oct 2021 11:19:01 UTC

Severity: minor

Found in version 29.0.50

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51075 in the body.
You can then email your comments to 51075 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to eggert <at> cs.ucla.edu, bug-gnu-emacs <at> gnu.org:
bug#51075; Package emacs. (Thu, 07 Oct 2021 11:19:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Basil L. Contovounesios" <contovob <at> tcd.ie>:
New bug report received and forwarded. Copy sent to eggert <at> cs.ucla.edu, bug-gnu-emacs <at> gnu.org. (Thu, 07 Oct 2021 11:19:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Uninitialised variable warning in src/term.c
Date: Thu, 07 Oct 2021 12:18:14 +0100
Severity: minor

I'm currently seeing the following warning with GCC 10.3.0:

In file included from term.c:30:
term.c: In function ‘encode_terminal_code’:
lisp.h:1853:35: warning: ‘gstring’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1853 |   return XVECTOR (array)->contents[idx];
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
term.c:553:16: note: ‘gstring’ was declared here
  553 |    Lisp_Object gstring;
      |                ^~~~~~~

I'm guessing it started with the following recent change:

Remove encode_terminal_code UNINITs
7e871dcd27 2021-10-03 17:52:28 -0700
https://git.sv.gnu.org/cgit/emacs.git/commit/?id=7e871dcd27

What's the best way to pacify it?  Do we care about doing so in GCC 10?

Is

  cmp = composition_table[src->u.cmp.id];

indeed guaranteed to be non-NULL?  If so, maybe gstring could be
initialised as nil and then easserted as non-nil in the !cmp branch
(eassuming cmp is non-NULL in the !src->u.cmp.automatic branch does not
make the warning go away).  If not, could there indeed be a bug?

Thanks,

-- 
Basil

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2021-10-07 built on tia
Repository revision: e338effc774f9a7cfe13d4a35dc1cf493a22c972
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure 'CC=ccache gcc' 'CFLAGS=-Og -ggdb3' --config-cache --prefix
 /home/blc/.local --enable-checking=structs --with-x-toolkit=lucid
 --with-file-notification=yes --with-x'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
seq gv subr-x byte-opt bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 50810 6940)
 (symbols 48 6621 1)
 (strings 32 18974 1858)
 (string-bytes 1 613497)
 (vectors 16 13616)
 (vector-slots 8 184446 10452)
 (floats 8 23 47)
 (intervals 56 231 0)
 (buffers 992 10))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51075; Package emacs. (Thu, 07 Oct 2021 13:03:01 GMT) Full text and rfc822 format available.

Message #8 received at 51075 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 51075 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#51075: 29.0.50; Uninitialised variable warning in src/term.c
Date: Thu, 07 Oct 2021 16:01:58 +0300
> Cc: Paul Eggert <eggert <at> cs.ucla.edu>
> Date: Thu, 07 Oct 2021 12:18:14 +0100
> From:  "Basil L. Contovounesios" via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> I'm currently seeing the following warning with GCC 10.3.0:
> 
> In file included from term.c:30:
> term.c: In function ‘encode_terminal_code’:
> lisp.h:1853:35: warning: ‘gstring’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>  1853 |   return XVECTOR (array)->contents[idx];
>       |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> term.c:553:16: note: ‘gstring’ was declared here
>   553 |    Lisp_Object gstring;
>       |                ^~~~~~~

It's a bogus warning.  It might be worth reporting to the GCC folks
(unless GCC 11 already fixed that).

> Is
> 
>   cmp = composition_table[src->u.cmp.id];
> 
> indeed guaranteed to be non-NULL?

If it's ever NULL, the very next line will segfault:

	      cmp = composition_table[src->u.cmp.id];
	      required = cmp->glyph_len;

> If so, maybe gstring could be
> initialised as nil and then easserted as non-nil in the !cmp branch
> (eassuming cmp is non-NULL in the !src->u.cmp.automatic branch does not
> make the warning go away).  If not, could there indeed be a bug?

Feel free to assign some value to gstring in the 'else' clause, to
shut up GCC in this case.




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Thu, 07 Oct 2021 20:14:02 GMT) Full text and rfc822 format available.

Notification sent to "Basil L. Contovounesios" <contovob <at> tcd.ie>:
bug acknowledged by developer. (Thu, 07 Oct 2021 20:14:02 GMT) Full text and rfc822 format available.

Message #13 received at 51075-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>, "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 51075-done <at> debbugs.gnu.org
Subject: Re: bug#51075: 29.0.50; Uninitialised variable warning in src/term.c
Date: Thu, 7 Oct 2021 13:13:33 -0700
[Message part 1 (text/plain, inline)]
On 10/7/21 06:01, Eli Zaretskii wrote:

> It's a bogus warning.  It might be worth reporting to the GCC folks
> (unless GCC 11 already fixed that).

Yes, I believed it's fixed in GCC 11. GCC 11.2.1 20210728 (Red Hat 
11.2.1-1) does not warn me about it.

> Feel free to assign some value to gstring in the 'else' clause, to
> shut up GCC in this case.

I installed into the emacs-28 branch the attached, which fixes it in a 
different way to make it a bit clearer to the reader that we're 
pacifying an inadequate compiler rather than executing odd code for an 
unknown reason.

There are a handful of other bogus warnings with GCC 11.2.1, which I'll 
try to get around to pacifying (I hope before GCC 12 comes out :-).
[0001-Pacify-GCC-10.3-Wmaybe-uninitialized.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51075; Package emacs. (Fri, 08 Oct 2021 10:22:02 GMT) Full text and rfc822 format available.

Message #16 received at 51075 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 51075 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#51075: 29.0.50; Uninitialised variable warning in src/term.c
Date: Fri, 08 Oct 2021 11:21:02 +0100
Eli Zaretskii [2021-10-07 09:02 -0400] wrote:

>> Cc: Paul Eggert <eggert <at> cs.ucla.edu>
>> Date: Thu, 07 Oct 2021 12:18:14 +0100
>> From:  "Basil L. Contovounesios" via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> Is
>> 
>>   cmp = composition_table[src->u.cmp.id];
>> 
>> indeed guaranteed to be non-NULL?
>
> If it's ever NULL, the very next line will segfault:
>
> 	      cmp = composition_table[src->u.cmp.id];
> 	      required = cmp->glyph_len;

Right, I didn't read carefully enough.

Thanks,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51075; Package emacs. (Fri, 08 Oct 2021 10:22:02 GMT) Full text and rfc822 format available.

Message #19 received at 51075 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 51075 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#51075: 29.0.50; Uninitialised variable warning in src/term.c
Date: Fri, 08 Oct 2021 11:21:11 +0100
Paul Eggert [2021-10-07 13:13 -0700] wrote:

> On 10/7/21 06:01, Eli Zaretskii wrote:
>
>> It's a bogus warning.  It might be worth reporting to the GCC folks
>> (unless GCC 11 already fixed that).
>
> Yes, I believed it's fixed in GCC 11. GCC 11.2.1 20210728 (Red Hat 11.2.1-1)
> does not warn me about it.
>
>> Feel free to assign some value to gstring in the 'else' clause, to
>> shut up GCC in this case.
>
> I installed into the emacs-28 branch the attached, which fixes it in a different
> way to make it a bit clearer to the reader that we're pacifying an inadequate
> compiler rather than executing odd code for an unknown reason.
>
> There are a handful of other bogus warnings with GCC 11.2.1, which I'll try to
> get around to pacifying (I hope before GCC 12 comes out :-).

Thanks!

-- 
Basil




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 05 Nov 2021 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 172 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.