This is the mail archive of the libc-help@sourceware.org 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] |
Other format: | [Raw text] |
Hi, I've recently tried to build eglibc from Debian's source package, but it aborted because of a failed test[1]: nptl/tst-eintr1. This test failed because one of the pthread_create calls returned EAGAIN. Indeed, after some time, instead of 12~23 threads, âgrep Threads /proc/$PID/statusâ reveals much more threads (up to several thousands). I've attached a simpler testcase that triggers the same issue, which I have been able to reproduce using a freshly-built glibc from GIT. I haven't observed this issue on single-processor systems (ran the test on a dedicated user with a RLIMIT_NPROC of NB_THREADS + 3 for hours without getting EAGAIN). Regards, Thibaut Girka.
#include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <sys/types.h> #include <unistd.h> #define NB_THREADS 20 void *thread_func(void *arg) { return arg; } int main(void) { unsigned int i = 0, j; void *result; pthread_t threads[NB_THREADS]; printf("Please watch /proc/%d/task as I'm running!\n", getpid()); /* Pre-spawn NB_THREAD threads */ for (j = 0; j < NB_THREADS; j++) { if (pthread_create(&threads[j], NULL, thread_func, (void *) j) != 0) { perror("pthread_create"); return 1; } } /* Now, close one thread, spawn another. FIFO style. */ while(1) { if (pthread_join(threads[i % NB_THREADS], &result) != 0) { perror("pthread_join"); break; } if ((unsigned int) result != (i % NB_THREADS)) { printf("Invalid reslut: %d!\n", (unsigned int) result); break; } if (pthread_create(&threads[i % NB_THREADS], NULL, thread_func, (void *) (i % NB_THREADS)) != 0) { perror("pthread_create"); break; } i += 1; if (i % 50000 == 0) printf("%d threads created\n", i); } printf("%d threads created\n", i); return 0; }
Attachment:
signature.asc
Description: Digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |