Bug#218931: SEVERE bug with ctype (isxdigit and co) in libc6 ds1-8 and ds1-9 (Sid) on i386
Package: libc6
Version: 2.3.2.ds1-9
(Note that I also tried the 2.3.2.ds1-8 with the same results as below).
I should also mention:
Package: libc6-dev
Version: 2.3.2.ds1-9
I apt-get dist-upgrade today my Sid (did it 10 days ago and it was still fine
at that time I guess). Now, the libc6 headers seem to be inconsistent with the
__ctype variable in the libc6 shared library and archive, or the __ctype
variable (in libc6 library) itself is broken. This causes the isxdigit() (at
least) function to behave incorrectly:
isxdigit('0') = 0
isxdigit('1') = 0
...
isxdigit('9') = 0
isxdigit('a') = 0
...
isxdigit('f') = 0
isxdigit('A') = 0
...
isxdigit('F') = 0
isxdigit('q') = 0
isxdigit('s') = 0
isxdigit('d') = 0
isxdigit('z') = 0
...
The source to get this was :
#include <ctype.h>
#include <stdio.h>
int main ()
{
char *p;
for (p = "0123456789abcdefABCDEFqsdzabcdef" ; *p != '\0'; p++)
printf("isxdigit('%c') = %d\n", *p, isxdigit(*p));
return 0;
}
(compiled with gcc-2.95 and gcc of the current gcc of the Sid, with shared
version of the libc6, and static version)
Other informations:
$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 4
model name : AMD Athlon(tm) Processor
stepping : 2
cpu MHz : 807.207
cache size : 256 KB
...
$ uname -a
Linux baloo 2.4.22 #2 mar aoû 26 23:26:24 CEST 2003 i686 GNU/Linux
$ gcc --version
gcc (GCC) 3.3.2 (Debian)
$ gcc-2.95 --version
2.95.4
$ echo $LC_ALL
fr_FR@euro
Please note that I get the same behaviour with LC_ALL unset !
Suggestion:
When I look in the libc6 headers, I get :
_ISxdigit = (1 << ( 4 ))
and :
isxdigit(c) expanded to (according to gcc -E -DM) :
(((__ctype_b) )[(int) ( ( c ) )] & (__ctype_mask_t) _ISxdigit
And, by looking the value of __ctype for '1' for example :
__ctype['1'] = 0xd808 (ie 1101100000001000 in base 2)
which means that the following bits are set :
3 (ie _ISdigit)
11 (ie _ISalnum)
12 (ie ????)
14 (ie ????)
15 (ie ????)
AND NOT the _ISxdigit bit !
Idem for __ctype['a'] = 0xd608 (ie 1101011000001000 in base 2), with the
following bits set:
3 (ie _ISdigit)
9 (ie _IScntrl)
10 (ie _ISpunct)
12 (ie ????)
14 (ie ????)
15 (ie ????)
Which looks completely broken !!!
So: what is wrong ? The ctype.h header ? Or the libc6.so and libc6.a libraries
? Or both ?
Please help !... The linux kernel won't compile anymore because of this
(cannot correctly generate drivers/char/consolemap_deftbl.c because isxdigit
is broken in drivers/char/conmakehash.c).
Thanks.
--
David Decotigny -- http://david.decotigny.free.fr
Reply to: