Subject: Re: The ELF ABI issue
To: Reinoud Zandijk <email@example.com>
From: Richard Earnshaw <firstname.lastname@example.org>
Date: 03/27/2002 12:09:06
> This is really .... disturbing IMHO ... you mean that if you use threads
> you can't just use a recursive function with a reasonable depth ? say a
> 1000 or 15000 ? and you can without threads ?
Many threading models (I can't say all, 'cos I really don't know) require
you to specify a stack size (or to pass a stack) when creating a new
thread. Necessarily, such stacks are not extensible, and if they aren't
big enough then your program will probably crash. For example, the
pthread_create function on Solaris says:
A new thread created with pthread_create() uses the stack
specified by the stackaddr attribute, and the stack contin-
ues for the number of bytes specified by the stacksize
attribute. By default, the stack size is 1 megabyte for 32-
bit processes and 2 megabyte for 64-bit processes (see
pthread_attr_setstacksize(3T)). If the default is used for
both the stackaddr and stacksize attributes,
pthread_create() creates a stack for the new thread with at
least 1 megabyte for 32-bit processes and 2 megabyte for
64-bit processes. (For customizing stack sizes, see NOTES).
It is usually very difficult to determine the runtime stack
requirements for a thread. PTHREAD_STACK_MIN specifies how
much stack storage is required to execute a NULL start_func.
The total runtime requirements for stack storage are
dependent on the storage required to do runtime linking, the
amount of storage required by library runtimes (as printf())
that your thread calls. Since these storage parameters are
not known before the program runs, it is best to use default
stacks. If you know your runtime requirements or decide to
use stacks that are larger than the default, then it makes
sense to specify your own stacks.