bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small stack size with libpthread?


From: Stephan Bergmann
Subject: Small stack size with libpthread?
Date: Wed, 25 Jun 2003 12:15:27 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312

Hi all.

In glibc-2.3.2/glibc-linuxthreads-2.3.2, code in pthread.c calls setrlimit(RLIMIT_STACK, ...) with a soft limit of

  max_stack = STACK_SIZE - __getpagesize();

(resulting in max_stack a little below 2MB with my Linux constellation.) This code is executed at the start of a -lpthread linked program, and cuts the stack size for the program's main thread. I have two questions about this:

1 Why is max_stack a hard value, that does not take into account the stacksize limit set by the user?

2 Why is there a call to setrlimit at all? I don't know the implementation details, but I would assume that setrlimit(RLIMIT_STACK, ...) only controls the size of the main thread's stack. Why is it changed? [I would also assume that calling setrlimit(RLIMIT_STACK, ...) can have only limited effect when a program is already executing, e.g., it should not enlarge the stack into already used address space, and it should not shrink the stack smaller than the current value of the stack pointer. But some tests show that the size of the main thread's stack is indeed cut by that call from pthread.c during initialization.]

I am asking this because we have a program component (the OpenOffice.org Basic interpreter) that runs in a multithreaded program, but is guaranteed to only ever run on the main thread, and can consume huge amounts of stack space. The easiest fix seemed to increase the stacksize limit in the shell script that starts the program, but that turned out to have no effect...

-Stephan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]