Bug 6976 - allocated thread stack size can be less than requested stack size
Summary: allocated thread stack size can be less than requested stack size
Status: RESOLVED DUPLICATE of bug 11787
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-24 01:59 UTC by Michael Kerrisk
Modified: 2014-07-02 06:06 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
test program (721 bytes, text/plain)
2008-10-24 02:01 UTC, Michael Kerrisk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2008-10-24 01:59:43 UTC
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;
Comment 1 Michael Kerrisk 2008-10-24 02:01:37 UTC
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
Comment 2 Siddhesh Poyarekar 2012-05-23 17:08:07 UTC
We're looking to fix this with bug 11787. Closing this as duplicate.

*** This bug has been marked as a duplicate of bug 11787 ***