public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/271] New: setlocale() kind-of not affecting threads when compile static
@ 2004-07-19 11:11 thomas at habets dot pp dot se
  2004-07-19 11:20 ` [Bug libc/271] " jakub at redhat dot com
  2004-07-22  2:48 ` gotom at debian dot or dot jp
  0 siblings, 2 replies; 3+ messages in thread
From: thomas at habets dot pp dot se @ 2004-07-19 11:11 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/271] setlocale() kind-of not affecting threads when compile static
  2004-07-19 11:11 [Bug libc/271] New: setlocale() kind-of not affecting threads when compile static thomas at habets dot pp dot se
@ 2004-07-19 11:20 ` jakub at redhat dot com
  2004-07-22  2:48 ` gotom at debian dot or dot jp
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at redhat dot com @ 2004-07-19 11:20 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2004-07-19 11:20 -------
It seems to be Debian specific (or using way too old glibc).
The testcase prints 1024 in all 3 cases when linked dynamically or statically,
linuxthreads or NPTL.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libc/271] setlocale() kind-of not affecting threads when compile static
  2004-07-19 11:11 [Bug libc/271] New: setlocale() kind-of not affecting threads when compile static thomas at habets dot pp dot se
  2004-07-19 11:20 ` [Bug libc/271] " jakub at redhat dot com
@ 2004-07-22  2:48 ` gotom at debian dot or dot jp
  1 sibling, 0 replies; 3+ messages in thread
From: gotom at debian dot or dot jp @ 2004-07-22  2:48 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From gotom at debian dot or dot jp  2004-07-22 02:48 -------
Correct, it's old glibc problem which is affected to debian.

-- 


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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-07-22  2:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-19 11:11 [Bug libc/271] New: setlocale() kind-of not affecting threads when compile static thomas at habets dot pp dot se
2004-07-19 11:20 ` [Bug libc/271] " jakub at redhat dot com
2004-07-22  2:48 ` gotom at debian dot or dot jp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).