GNU bug report logs - #8600
struct charset.code_space[15] contains garbage

Previous Next

Package: emacs;

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

Date: Sun, 1 May 2011 17:00:05 UTC

Severity: normal

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 8600 in the body.
You can then email your comments to 8600 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#8600; Package emacs. (Sun, 01 May 2011 17:00:05 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. (Sun, 01 May 2011 17:00:05 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
Subject: struct charset.code_space[15] contains garbage
Date: Sun, 01 May 2011 09:59:25 -0700
While testing the 32+64 port I noticed that a too-wide value
is stuffed into charset.code_space[15], which means that
slot has a garbage value (at least, it's garbage on typical
machines with 32-bit int).  As far as I can see, the garbage
value is never used, so it's a bit cleaner to never compute
or store it.

I plan to install the following patch to do that.
This patch is relevant to ordinary 32- and 64-bit hosts, too,
so I'm separating it out.

* charset.h (struct charset.code_space): Now has 15 elements, not 16.
* charset.c (Fdefine_charset_internal): Don't initialize
charset.code_space[15].  The value was garbage, on hosts with
32-bit int.
=== modified file 'src/charset.c'
--- src/charset.c	2011-04-26 06:17:52 +0000
+++ src/charset.c	2011-05-01 06:28:23 +0000
@@ -869,7 +869,7 @@
   ASET (attrs, charset_name, args[charset_arg_name]);

   val = args[charset_arg_code_space];
-  for (i = 0, dimension = 0, nchars = 1; i < 4; i++)
+  for (i = 0, dimension = 0, nchars = 1; ; i++)
     {
       int min_byte, max_byte;

@@ -880,10 +880,12 @@
       charset.code_space[i * 4] = min_byte;
       charset.code_space[i * 4 + 1] = max_byte;
       charset.code_space[i * 4 + 2] = max_byte - min_byte + 1;
+      if (max_byte > 0)
+	dimension = i + 1;
+      if (i == 3)
+	break;
       nchars *= charset.code_space[i * 4 + 2];
       charset.code_space[i * 4 + 3] = nchars;
-      if (max_byte > 0)
-	dimension = i + 1;
     }

   val = args[charset_arg_dimension];

=== modified file 'src/charset.h'
--- src/charset.h	2011-04-11 06:48:18 +0000
+++ src/charset.h	2011-05-01 16:22:33 +0000
@@ -155,10 +155,11 @@
      byte code of the (N+1)th dimension, <code_space>[4N+1] is a
      maximum byte code of the (N+1)th dimension, <code_space>[4N+2] is
      (<code_space>[4N+1] - <code_space>[4N] + 1), <code_space>[4N+3]
-     is a number of characters containd in the first to (N+1)th
-     dismesions.  We get `char-index' of a `code-point' from this
+     is the number of characters contained in the first through (N+1)th
+     dimensions, except that there is no <code_space>[15].
+     We get `char-index' of a `code-point' from this
      information.  */
-  int code_space[16];
+  int code_space[15];

   /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit
      of code_space_mask[B] is set.  This array is used to quickly





Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Fri, 06 May 2011 07:31:02 GMT) Full text and rfc822 format available.

Notification sent to Paul Eggert <eggert <at> cs.ucla.edu>:
bug acknowledged by developer. (Fri, 06 May 2011 07:31:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 8545 <at> debbugs.gnu.org, 8600-done <at> debbugs.gnu.org, 
	8601-done <at> debbugs.gnu.org, 8602-done <at> debbugs.gnu.org
Subject: Merged fixes for 8600, 8601, 8602, and (partially) for 8545
Date: Fri, 06 May 2011 00:29:56 -0700
I committed to the Emacs trunk a merge (bzr 104134) that has fixes for
the following bugs:

* Bug#8600 - The fix removes the garbage element of code_space.

* Bug#8601 - Here I assumed that the "* 2" is a typo.

* Bug#8602 - This fixes some large-int-to-float screwups in
             the Lisp reader.

* Bug#8545 - This fixes the bug where the code should have called
             va_copy, but didn't.  Also, I changed a limit so that
	     the MOST_POSITIVE_FIXNUM limit for strings applies to
	     their length, i.e., does not include the null termination
	     byte.  Stefan hasn't had time to chime in, but if this
             last change turns out to be incorrect I will back it out.

This merge doesn't entirely fix Bug#8545, so I'll leave that bug open;
the others I'll close.




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

This bug report was last modified 12 years and 351 days ago.

Previous Next


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