Solution to my linuxthreads problem
Andreas Jaeger
aj@suse.de
Mon Dec 20 09:34:00 GMT 1999
Yesterday I reported a problem with the current glibc when using
headers from 2.3.33 on a Linux 2.2.13 system. Together with Andreas
Schwab we've fixed this with the appended patch. The problem is that
ugetrlimit doesn't exist and therefore errno is set - but errno is not
initialized yet. The solution is to move the getrlimit call after
errno has been set.
Andreas
1999-12-20 Andreas Jaeger <aj@suse.de>
* pthread.c (pthread_initialize): Move getrlimit call after
setting of errno.
===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/pthread.c,v
retrieving revision 1.17.2.6
diff -u -c -r1.17.2.6 pthread.c
cvs server: conflicting specifications of output style
*** pthread.c 1999/11/22 20:41:55 1.17.2.6
--- pthread.c 1999/12/20 17:28:28
***************
*** 289,303 ****
STACK_SIZE boundary. */
__pthread_initial_thread_bos =
(char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1));
- /* Play with the stack size limit to make sure that no stack ever grows
- beyond STACK_SIZE minus two pages (one page for the thread descriptor
- immediately beyond, and one page to act as a guard page). */
- getrlimit(RLIMIT_STACK, &limit);
- max_stack = STACK_SIZE - 2 * __getpagesize();
- if (limit.rlim_cur > max_stack) {
- limit.rlim_cur = max_stack;
- setrlimit(RLIMIT_STACK, &limit);
- }
/* Update the descriptor for the initial thread. */
__pthread_initial_thread.p_pid = __getpid();
/* If we have special thread_self processing, initialize that for the
--- 289,294 ----
***************
*** 308,313 ****
--- 299,314 ----
/* The errno/h_errno variable of the main thread are the global ones. */
__pthread_initial_thread.p_errnop = &_errno;
__pthread_initial_thread.p_h_errnop = &_h_errno;
+ /* Play with the stack size limit to make sure that no stack ever grows
+ beyond STACK_SIZE minus two pages (one page for the thread descriptor
+ immediately beyond, and one page to act as a guard page). */
+ /* errno must be set for system calls. */
+ getrlimit(RLIMIT_STACK, &limit);
+ max_stack = STACK_SIZE - 2 * __getpagesize();
+ if (limit.rlim_cur > max_stack) {
+ limit.rlim_cur = max_stack;
+ setrlimit(RLIMIT_STACK, &limit);
+ }
#ifdef __SIGRTMIN
/* Initialize real-time signals. */
init_rtsigs ();
More information about the Libc-hacker
mailing list