pthread_create fails on a device with 16MB RAM

Carmelo AMOROSO carmelo.amoroso at st.com
Tue Feb 1 17:27:31 UTC 2011


On 2/1/2011 5:54 PM, Peter Korsgaard wrote:
>  >>>>> "Carmelo" == Carmelo AMOROSO <carmelo.amoroso at st.com> writes:
> 
> Hi,
> 
> Carmelo> --- a/libpthread/nptl/init.c
> Carmelo> +++ b/libpthread/nptl/init.c
> Carmelo> @@ -401,6 +401,10 @@ __pthread_initialize_minimal_internal (v
> Carmelo> Use the minimal size acceptable. */
> Carmelo> limit.rlim_cur = PTHREAD_STACK_MIN;
> 
> Carmelo> + /* Do not exceed architecture specific default */
> Carmelo> + if (limit.rlim_cur > ARCH_STACK_DEFAULT_SIZE)
> Carmelo> + limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
> Carmelo> +
> Carmelo> /* Make sure it meets the minimum size that allocate_stack
> Carmelo> (allocatestack.c) will demand, which depends on the page size. */
> Carmelo> const uintptr_t pagesz = sysconf (_SC_PAGESIZE);
> 
> Carmelo> At least the check should be guarded by #ifdef ARCH_STACK_DEFAULT_SIZE.
> 
> It's already used in the same file without a guard.
> 

you're right.

> Carmelo> Anyway, where are you thinking to define this one ?
> 
> Seems like most archs sets it to 2MB:
> the 
> git grep ARCH_STACK_DEFAULT_SIZE
> libpthread/nptl/init.c: limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
> libpthread/nptl/sysdeps/alpha/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (4 * 
> 1024 * 1024)
> libpthread/nptl/sysdeps/arm/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (2 * 
> 1024 * 1024)
> libpthread/nptl/sysdeps/i386/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (2 * 
> 1024 * 1024)
> libpthread/nptl/sysdeps/mips/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (2 * 
> 1024 * 1024)
> libpthread/nptl/sysdeps/powerpc/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (4 
> * 1024 * 1024)
> libpthread/nptl/sysdeps/sh/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (2 * 
> 1024 * 1024)
> libpthread/nptl/sysdeps/sparc/sparc32/pthreaddef.h:#define 
> ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
> libpthread/nptl/sysdeps/sparc/sparc64/pthreaddef.h:#define 
> ARCH_STACK_DEFAULT_SIZE (4 * 1024 * 1024)
> libpthread/nptl/sysdeps/x86_64/pthreaddef.h:#define ARCH_STACK_DEFAULT_SIZE (2 * 
> 1024 * 1024)
> 

(I did not find it... likely a typo in using grep.)

Ok, but this value is used as a fall-back if system rlimit is bad. Now
the proposal is to use it as a upper-bound, and there will no way to use
a larger value is needed (for some reason). While the current
implementation is more flexible, allowing to set a value that fit better
with the user needs. The only concern I have against this patch.


Carmelo
> 
> --
> Bye, Peter Korsgaard
> 


More information about the uClibc mailing list