GNU bug report logs - #8229
possibly uninitialized variable in load_charset

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Fri, 11 Mar 2011 00:25:01 UTC

Severity: minor

Done: Eli Zaretskii <eliz <at> gnu.org>

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 8229 in the body.
You can then email your comments to 8229 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8229; Package emacs. (Fri, 11 Mar 2011 00:25:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert <at> cs.ucla.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 11 Mar 2011 00:25:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: bug-gnu-emacs <at> gnu.org
Cc: Kenichi Handa <handa <at> m17n.org>
Subject: possibly uninitialized variable in load_charset
Date: Thu, 10 Mar 2011 16:24:13 -0800
Severity: minor

I found this problem by compiling Emacs with GCC's -Wuninitialized flag.

The following code in the Emacs trunk src/charset.c's load_charset
function is suspicious, because as written it appears that it might be
using an uninitialized variable:

  if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP)
    map = CHARSET_MAP (charset);
  else if (CHARSET_UNIFIED_P (charset))
    map = CHARSET_UNIFY_MAP (charset);
  if (STRINGP (map))
    ...

The last if-test uses "map", but it's not clear from the previous
tests that "map" must be initialized.

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

  else if (CHARSET_UNIFIED_P (charset))
    map = CHARSET_UNIFY_MAP (charset);

with:

  else
    {
      if (! CHARSET_UNIFIED_P (charset))
	abort ();
      map = CHARSET_UNIFY_MAP (charset);
    }

I'm CC'ing this to Kenichi Handa, who committed the code in question.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8229; Package emacs. (Wed, 23 Mar 2011 23:20:05 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 8229 <at> debbugs.gnu.org, 8215 <at> debbugs.gnu.org, 8211 <at> debbugs.gnu.org
Subject: committed the workaround
Date: Wed, 23 Mar 2011 16:19:24 -0700
I committed my abovementioned workaround into the
Emacs trunk on 2011-03-11 (bzr 103589).  I don't
consider this a fix, though, so I'm leaving this
bug report open.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8229; Package emacs. (Wed, 02 Jun 2021 08:04:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 8211 <at> debbugs.gnu.org, 8229 <at> debbugs.gnu.org, 8215 <at> debbugs.gnu.org
Subject: Re: bug#8229: possibly uninitialized variable in load_charset
Date: Wed, 02 Jun 2021 10:03:14 +0200
Paul Eggert <eggert <at> cs.ucla.edu> writes:

> I committed my abovementioned workaround into the
> Emacs trunk on 2011-03-11 (bzr 103589).  I don't
> consider this a fix, though, so I'm leaving this
> bug report open.

This was ten years ago:

commit 0ac2c2991c1cba4e3c6e5f7b62c7d61b01d69994
Author:     Paul Eggert <eggert <at> cs.ucla.edu>
AuthorDate: Mon Mar 7 16:46:23 2011 -0800
Commit:     Paul Eggert <eggert <at> cs.ucla.edu>
CommitDate: Mon Mar 7 16:46:23 2011 -0800

    * charset.c (load_charset): Abort instead of using uninitialized var.

The code is still pretty much identical, as far as I can tell.  Should
this report be closed now?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 02 Jun 2021 12:52:02 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> cs.ucla.edu>:
bug acknowledged by developer. (Wed, 02 Jun 2021 12:52:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 8229-done <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#8215: bug#8229: possibly uninitialized variable in
 load_charset
Date: Wed, 02 Jun 2021 15:50:50 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Wed, 02 Jun 2021 10:03:14 +0200
> Cc: 8211 <at> debbugs.gnu.org, 8229 <at> debbugs.gnu.org, 8215 <at> debbugs.gnu.org
> 
> Paul Eggert <eggert <at> cs.ucla.edu> writes:
> 
> > I committed my abovementioned workaround into the
> > Emacs trunk on 2011-03-11 (bzr 103589).  I don't
> > consider this a fix, though, so I'm leaving this
> > bug report open.
> 
> This was ten years ago:
> 
> commit 0ac2c2991c1cba4e3c6e5f7b62c7d61b01d69994
> Author:     Paul Eggert <eggert <at> cs.ucla.edu>
> AuthorDate: Mon Mar 7 16:46:23 2011 -0800
> Commit:     Paul Eggert <eggert <at> cs.ucla.edu>
> CommitDate: Mon Mar 7 16:46:23 2011 -0800
> 
>     * charset.c (load_charset): Abort instead of using uninitialized var.
> 
> The code is still pretty much identical, as far as I can tell.  Should
> this report be closed now?

I'm closing it.  I think non-unified charsets are rarely if ever used
in Emacs these days, but in any case, we have emacs_abort there, so if
the problem ever rears its ugly head, we will catch it.




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

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

Previous Next


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