pthread_create fails on a device with 16MB RAM

Peter Korsgaard jacmet at sunsite.dk
Tue Feb 1 16:54:58 UTC 2011


>>>>> "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.

 Carmelo> Anyway, where are you thinking to define this one ?

Seems like most archs sets it to 2MB:

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)


-- 
Bye, Peter Korsgaard


More information about the uClibc mailing list