From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15780 invoked by alias); 4 Dec 2007 01:41:58 -0000 Received: (qmail 15763 invoked by uid 48); 4 Dec 2007 01:41:47 -0000 Date: Tue, 04 Dec 2007 01:41:00 -0000 From: "ryo at np dot css dot fujitsu dot com" To: glibc-bugs@sources.redhat.com Message-ID: <20071204014146.5443.ryo@np.css.fujitsu.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/5443] New: SIGSEGV occurs in strerror_r() X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00008.txt.bz2 1. Summary: strerror_r() can use in multi-threaded applications, but rarely SIGSEGV occurs in strerror_r() with using setlocale() in other threads. 2. hardware dependency: none. 3. Description of Problem: SIGSEGV occurs in strerror_r(). 4. How reproducible: rarely, but it happen. 5. Step to Reproduce: The following test program can reproduce the problems. tst-strerror.tar.gz To make reproduction easy, this program executes strerror_r(), printf(), setlocale() at the same time by a lot of threads. 1) Extract the archive file. The following files are extracted. Makefile tst-strerror.c 2) Compile the test program. # make 3) Run the test program. # ./tst-strerror Run the test programs in several times, SIGSEGV occurs. 6. Actual Result: SIGSEGV occurs in strerror_r(). 7. Expected Result: strerror_r() execute normally. ------------------------------ Makefile: CC=gcc CFLAGS=-g -Wall -lpthread PROGS= tst-strerror all: $(PROGS) .c: $(CC) $(CFLAGS) -o $* $*.c $(PROGS): clean: rm -f $(PROGS) ------------------------------- tst-strerror.c: #include #include #include #include #include #include #include #include "pthread.h" #include #include #include #include #include #define ENVCOUNT_MAX 100 #define MAXTHREAD 100 static int start; static void * process_setlocale_1(void *arg) { int i,s; char *result; while(!start) sched_yield(); s = 0; for (i = 0; ; i++) { switch (s) { case 0: result = setlocale ( LC_MESSAGES, "el_GR.utf8" ); s++; break; case 1: result = setlocale ( LC_MESSAGES, "en_CA.iso88591" ); s++; break; case 2: result = setlocale ( LC_MESSAGES, "es_DO" ); s++; break; case 3: result = setlocale ( LC_MESSAGES, "et_EE.utf8" ); s++; break; default : s = 0; } } return NULL; } static void * taikou_strerror(void *arg) { int i; char *buf; buf = malloc ( 1024 ); extern int errno; while(!start) sched_yield(); for (i = 0; ; i++) { strerror_r ( errno, buf, 1024 ); printf ( " errno = %d : %s \n ", errno, buf); } return NULL; } int main (void) { int retcode; pthread_t th[MAXTHREAD]; pthread_attr_t attr[MAXTHREAD]; char s[MAXTHREAD][7]; int i; void *result; start = 0; i = 0; pthread_attr_init(&attr[i]); pthread_attr_setstacksize(&attr[i],PTHREAD_STACK_MIN); sprintf(s[i], "A%05d", i); retcode = pthread_create (&th[i], &attr[i], process_setlocale_1, (void *) s[i]); if (retcode != 0) { fprintf (stderr, "create a failed (wordexp) %d\n", retcode); } for (i = 1; i < MAXTHREAD; i++) { pthread_attr_init(&attr[i]); pthread_attr_setstacksize(&attr[i],PTHREAD_STACK_MIN); sprintf(s[i], "A%05d", i); retcode = pthread_create (&th[i], &attr[i], taikou_strerror, (void *) s[i]); if (retcode != 0) { fprintf (stderr, "create a failed (getenv) %d\n", retcode); } } sleep(0); start = 1; sleep(0); for (i = 0; i < MAXTHREAD ; i++) { pthread_join(th[i],&result); } printf("end\n"); return 0; } -------------------------------------------------------------------- -- Summary: SIGSEGV occurs in strerror_r() Product: glibc Version: unspecified Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper at redhat dot com ReportedBy: ryo at np dot css dot fujitsu dot com CC: glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=5443 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.