• Elliott Hughes's avatar
    Fix pthread_getattr_np for the main thread. · 64218234
    Elliott Hughes authored
    
    
    On most architectures the kernel subtracts a random offset to the stack
    pointer in create_elf_tables by calling arch_align_stack before writing
    the auxval table and so on. On all but x86 this doesn't cause a problem
    because the random offset is less than a page, but on x86 it's up to two
    pages. This means that our old technique of rounding the stack pointer
    doesn't work. (Our old implementation of that technique was wrong too.)
    
    It's also incorrect to assume that the main thread's stack base and size
    are constant. Likewise to assume that the main thread has a guard page.
    The main thread is not like other threads.
    
    This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK)
    whenever we're asked.
    
    Bug: 17111575
    Signed-off-by: default avatarFengwei Yin <fengwei.yin@intel.com>
    
    (cherry picked from commit 57b7a611)
    
    Change-Id: I87e679ee1c0db8092f2d1221c8e7c1461545c5a4
    64218234