For pthread_attr_setstacksize(), POSIX.1-2001 says: "The stacksize attribute shall define the minimum stack size (in bytes) allocated for the created threads stack." However, under NPTL, the allocated stack (as reported by pthread_getattr_np()) can be up to [STACK_MIN - 1] (15 on x86-32) bytes less than was requested. The problem line looks to be the following line in nptl/allocatestak.c: size &= ~__static_tls_align_m1; which should probably be something like: size = (size + __static_tls_align_m1 + 1) & ~__static_tls_align_m1;
Created attachment 3021 [details] test program The attached program can be used to test. Here's some examples: $ uname -i i386 $ ./a.out 0x400f Attributes of created thread: Stack address = 0xb7fe6000 (EOS = 0xb7fea000) Stack size = 0x4000 (16384) bytes $ ./a.out 0x5161f Attributes of created thread: Stack address = 0xb7d7c000 (EOS = 0xb7dcd610) Stack size = 0x51610 (333328) bytes
We're looking to fix this with bug 11787. Closing this as duplicate. *** This bug has been marked as a duplicate of bug 11787 ***