This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[jury gerold <gjury@grips.com>] locale and pthreads do not work together



I can reproduce the reported problem with 2.2.1, just adding -lpthread
is enough to get this segfault in the strfmon call:

(gdb) r 12345
Starting program: /suse/aj/tmp/./formattest 12345
[New Thread 1024 (LWP 19432)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 19432)]
0x4002f6a9 in pthread_mutex_init () from /lib/libpthread.so.0
(gdb) bt
#0  0x4002f6a9 in pthread_mutex_init () from /lib/libpthread.so.0
#1  0x400ad0e7 in _IO_no_init () from /lib/libc.so.6
#2  0x400ad029 in _IO_init () from /lib/libc.so.6
#3  0x40088674 in strfmon () from /lib/libc.so.6
#4  0x804854f in main (argc=2, argv=0xbffff724) at formattest.c:19
#5  0x4005abaf in __libc_start_main () from /lib/libc.so.6

Andreas

Subject: Topics

Topics:
   locale and pthreads do not work together



The following little program fails on various versions of glibc + linux-threads
up to version 2.2.1

I regenerated all the locales, used localedef in various ways.
Nothing helps.
As soon as the pthreads library is involved, locales refuse to work for me.

Anyone with an idea what i am doing wrong ?

Best Regards

Gerold


/*
 compile with 
   gcc -Wall -D_REENTRANT -o formattest formattest.c -lpthread
   formattest 12345 -> segfault

 compile with 
   gcc -Wall -D_REENTRANT -o formattest formattest.c
   formattest 12345 -> ok

 compile with 
   gcc -Wall -o formattest formattest.c
   formattest 12345 -> ok
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <monetary.h>

int main( int argc, char *argv[] )
{
  char *fail = 0;
  double d;
  char rbuf[128];

  if( argc < 2 ) {
    printf( "usage : %s number\n", argv[0] );
    return 0;
  }
  setlocale( LC_MONETARY, "" );
  d = strtod( argv[1], &fail );
  strfmon( rbuf, sizeof( rbuf ), "%n", d );
  printf( "%s\n", rbuf );
  return 0;
}





-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]