This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/271] New: setlocale() kind-of not affecting threads when compile static
- From: "thomas at habets dot pp dot se" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 19 Jul 2004 11:11:23 -0000
- Subject: [Bug libc/271] New: setlocale() kind-of not affecting threads when compile static
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
isalpha(0xfc) returns 0 in a thread even though setlocale() set a locale where
it's supposed to return non-zero when compiled static. The bug does not exist in
glibc 2.2.5 (debian woody/stable 3.0).
Even if you would consider this debians problem and not yours for some reason
(patches or something), please try the code below on an "approved" glibc system.
It's supposed to return non-zero to all isalpha() calls. Thanks.
When compiling non-static, it behaves as expected:
$ gcc -o loc loc.c -lpthread && ./loc
main isalpha(): 1024
thread current locale: sv_SE.ISO-8859-1
thread isalpha() pre-setlocale(): 1024
main isalpha(): 1024
When compiled static, it's buggy:
$ gcc -o loc loc.c -lpthread -static && ./loc
main isalpha(): 1024
thread current locale: sv_SE.ISO-8859-1
thread isalpha() pre-setlocale(): 0 <-------- zero? wtf?
main isalpha(): 1024
When the thread does a back-and-forth setlocale() before isalpha(), the code
works, see "if (0)" in the code.
I've tried compiling with gcc 2.95.4 with the same results. When I compiled on a
debian woody box, the thing worked as expected. I've tried copying the binary
back and forth, and it's only the binary compiled statically on debian sarge
(libc 2.3.2) and run anywhere that has the problem.
Software versions:
---
debian sarge x86
libc6 2.3.2.ds1-13 (debian package)
linux 2.6.6
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.4/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.4 (Debian 1:3.3.4-2)
GNU ld version 2.14.90.0.7 20031029 Debian GNU/Linux
test program:
#include<pthread.h>
#include<stdio.h>
#include<locale.h>
#include<assert.h>
static char ch = '\xfc';
static void *thr(void *p)
{
const char *locale = "sv_SE.iso88591";
const char *locale2 = "sv_SE.ISO-8859-1";
printf("thread current locale: %s\n", setlocale(LC_ALL, NULL));
printf("thread isalpha() pre-setlocale(): %d\n", isalpha(ch));
if (0) {
assert(setlocale(LC_ALL, locale));
printf("thread isalpha() after one setlocale(): %d\n", isalpha(ch));
if (0) {
assert(setlocale(LC_ALL, locale2));
printf("thread isalpha() after two setlocale(): %d\n", isalpha(ch));
}
}
}
int main()
{
const char *locale = "sv_SE.ISO-8859-1";
pthread_t p;
assert(setlocale(LC_ALL, locale));
printf("main isalpha(): %d\n", isalpha(ch));
sleep(1);
pthread_create(&p, NULL, thr, NULL);
sleep(1);
printf("main isalpha(): %d\n", isalpha(ch));
}
--
Summary: setlocale() kind-of not affecting threads when compile
static
Product: glibc
Version: 2.3.2
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: thomas at habets dot pp dot se
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=271
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.