History log of /bionic/libc/bionic/pthread_attr.cpp
Revision Date Author Comments
569333293aeefbe792826cd59140dc23704018c4 11-Sep-2015 Mor-sarid, Nitzan <nitzan.mor-sarid@intel.com> Fix the way to get main thread stack start address.

For previous way to get the stack using the [stack] string from
/proc/self/task/<pid>/maps is not enough. On x86/x86_64, if an
alternative signal stack is used while a task switch happens,
the [stack] indicator may no longer be correct.

Instead, stack_start from /proc/self/stat which is always inside
the main stack, is used to find the main stack in /proc/self/maps.

Change-Id: Ieb010e71518b57560d541cd3b3563e5aa9660750
Signed-off-by: Nitzan Mor-sarid <nitzan.mor-sarid@intel.com>
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
58cf31b50699ed9f523de38c8e943f3bbd1ced9e 07-Mar-2015 Yabin Cui <yabinc@google.com> Make pthread join_state not protected by g_thread_list_lock.

1. Move the representation of thread join_state from pthread.attr.flag
to pthread.join_state. This clarifies thread state change.
2. Use atomic operations for pthread.join_state. So we don't need to
protect it by g_thread_list_lock. g_thread_list_lock will be reduced
to only protect g_thread_list or even removed in further changes.

Bug: 19636317
Change-Id: I31fb143a7c69508c7287307dd3b0776993ec0f43
9d0c79304d2413028aa5c213f7a567f00feccde5 06-Mar-2015 Yabin Cui <yabinc@google.com> Remove PTHREAD_ATTR_FLAG_MAIN_THREAD.

Make this change because I think it is more reasonable to check stack info
in pthread_getattr_np. I believe pthread_attr_t is not tied with any thread,
and can't have a flag saying who using it is the main thread.
This change also helps refactor of g_thread_list_lock.

Bug: 19636317
Change-Id: Iedbb85a391ac3e1849dd036d01445dac4bc63db9
2f25cf373ca7c875956a7c06483b30d381296817 09-Oct-2014 Elliott Hughes <enh@google.com> Fix pthread_attr_getstack under valgrind.

valgrind seems to mess with the stack enough that the kernel will
report "[stack:pid]" rather than "[stack]" in /proc/self/maps, so
switch to the task-specific file instead to force "[stack]". (There
are two conditions in the kernel code that decides which form to
output.)

Bug: 17897476

(cherry picked from commit 9afb2f2106a5d659854c175c574c1c31e0e205a2)

Change-Id: I92c331ef6fb5868af49e75bc595710d290a95f5b
9afb2f2106a5d659854c175c574c1c31e0e205a2 09-Oct-2014 Elliott Hughes <enh@google.com> Fix pthread_attr_getstack under valgrind.

valgrind seems to mess with the stack enough that the kernel will
report "[stack:pid]" rather than "[stack]" in /proc/self/maps, so
switch to the task-specific file instead to force "[stack]". (There
are two conditions in the kernel code that decides which form to
output.)

Bug: 17897476
Change-Id: Iff85ceb6d52e8716251fab4e45d95a27184c5529
67f1f3b171ecd5f68f51465bbe4b8c8440bb6b2e 28-Aug-2014 Elliott Hughes <enh@google.com> Have pthread_attr_getstack for the main thread report RLIMIT_STACK...

...rather than just what's already mapped in. This seems somewhat
contrary to POSIX's "All pages within the stack described by stackaddr
and stacksize shall be both readable and writable by the thread", but
it's what glibc does.

Bug: 17111575

(cherry picked from commit 9e4ffa7032eaab308876b8e3da86b05c3c613878)

Change-Id: I73f219a569917b2e4546c09436d7ef5231facc07
9e4ffa7032eaab308876b8e3da86b05c3c613878 28-Aug-2014 Elliott Hughes <enh@google.com> Have pthread_attr_getstack for the main thread report RLIMIT_STACK...

...rather than just what's already mapped in. This seems somewhat
contrary to POSIX's "All pages within the stack described by stackaddr
and stacksize shall be both readable and writable by the thread", but
it's what glibc does.

Bug: 17111575
Change-Id: If9e2dfad9a603c0d0615a8123aacda4946e95b2c
642182341018b282148280a7bdb771493e15bd7d 26-Aug-2014 Elliott Hughes <enh@google.com> Fix pthread_getattr_np for the main thread.

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: Fengwei Yin <fengwei.yin@intel.com>

(cherry picked from commit 57b7a6110e7e8b446fc23cce4765ff625ee0a105)

Change-Id: I87e679ee1c0db8092f2d1221c8e7c1461545c5a4
57b7a6110e7e8b446fc23cce4765ff625ee0a105 26-Aug-2014 Elliott Hughes <enh@google.com> Fix pthread_getattr_np for the main thread.

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: Fengwei Yin <fengwei.yin@intel.com>
Change-Id: I1d4dbffe7bc7bda1d353c3a295dbf68d29f63158
a4eafa6dbc98378f3fa759fec8590871e2b5ae29 10-Mar-2014 Calin Juravle <calin@google.com> Removed pthread_attr_getstackaddr/pthread_attr_setstackaddr

Moved existing definitions to ndk_cruft to preserve NDK compatibility.

Bug: 13281069
Change-Id: I6f260de69afa55a6274f0d13145c19ac6517b9d5
f0870c3bfeba99482392fafe6d5f49615393c2b1 21-Feb-2014 Halton Huo <halton.huo@intel.com> Fix some pthread symbols build as C++ symbol under x64 lunch.

Functions protected with !defined(__LP64__) will be get build as C++
symbols for X64 build. This is not the desired work. So protect the
implementation with !defined(__LP64__) as well.

Change-Id: I4ef50ec36e46289ab308063e24f6c5ac61a6ca8d
c3f114037dbf028896310609fd28cf2b3da99c4d 30-Oct-2013 Elliott Hughes <enh@google.com> <pthread.h> fixes and pthread cleanup.

<pthread.h> was missing nonnull attributes, noreturn on pthread_exit,
and had incorrect cv qualifiers for several standard functions.

I've also marked the non-standard stuff (where I count glibc rather
than POSIX as "standard") so we can revisit this cruft for LP64 and
try to ensure we're compatible with glibc.

I've also broken out the pthread_cond* functions into a new file.

I've made the remaining pthread files (plus ptrace) part of the bionic code
and fixed all the warnings.

I've added a few more smoke tests for chunks of untested pthread functionality.

We no longer need the libc_static_common_src_files hack for any of the
pthread implementation because we long since stripped out the rest of
the armv5 support, and this hack was just to ensure that __get_tls in libc.a
went via the kernel if necessary.

This patch also finishes the job of breaking up the pthread.c monolith, and
adds a handful of new tests.

Change-Id: Idc0ae7f5d8aa65989598acd4c01a874fe21582c7
405f8553cf19c583158d59ab44a5d668eade360d 02-Oct-2013 Elliott Hughes <enh@google.com> Remove more assumptions that pointers are 32-bit.

Change-Id: I2157e2fc4db7692b746c697982c3d028a056462a
50af69e8f326b2762a44d5fea2b118e7616e5d20 14-Sep-2013 Brian Carlstrom <bdc@google.com> Simplify main thread stack size initialization

Change-Id: Iec09433d9de501031cce09dc75848a5e8f3d96bf
84114c8dd5b17efecf7988f263ce431208d7be5a 17-Jul-2013 Elliott Hughes <enh@google.com> Improve stack overflow diagnostics (take 2).

This reverts commits eb1b07469f2b5a392dc1bfd8adc211aea8c72bc5 and
d14dc3b87fbf80553f1cafa453816b7f11366627, and fixes the bug where
we were calling mmap (which might cause errno to be set) before
__set_tls (which is required to implement errno).

Bug: 8557703
Change-Id: I2c36d00240c56e156e1bb430d8c22a73a068b70c
d14dc3b87fbf80553f1cafa453816b7f11366627 17-Jul-2013 Guang Zhu <guangzhu@google.com> Revert "Improve stack overflow diagnostics."

This reverts commit aa754dca90487356cabf07ade0e8d88c2630b784.

Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
aa754dca90487356cabf07ade0e8d88c2630b784 16-Jul-2013 Elliott Hughes <enh@google.com> Improve stack overflow diagnostics.

We notify debuggerd of problems by installing signal handlers. That's
fine except for when the signal is caused by us running off the end of
a thread's stack and into the guard page.

Bug: 8557703
Change-Id: I1ef65b4bb3bbca7e9a9743056177094921e60ed3
b95cf0d23a1db3b7c37bd98b0c86196796c9b029 15-Jul-2013 Elliott Hughes <enh@google.com> Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.

pthread_getattr_np was reporting the values supplied to us, not the values we
actually used, which is kinda the whole point of pthread_getattr_np.

pthread_attr_setguardsize and pthread_attr_setstacksize were reporting EINVAL
for any size that wasn't a multiple of the system page size. This is
unnecessary. We can just round like POSIX suggests and glibc already does.

Also improve the error reporting for pthread_create failures.

Change-Id: I7ebc518628a8a1161ec72e111def911d500bba71
6d339182070b035ca94f19bc37c94f4d9813c374 13-Feb-2013 Elliott Hughes <enh@google.com> Simplify pthread_create, using more public API.

Change-Id: I08e65ba88ed01436223e4e528631c9e41ec0e7f4
3e898476c7230b60a0f76968e64ff25f475b48c0 12-Feb-2013 Elliott Hughes <enh@google.com> Revert "Revert "More pthreads cleanup.""

This reverts commit 6f94de3ca49e4ea147b1c59e5818fa175846518f

(Doesn't try to increase the number of TLS slots; that leads to
an inability to boot. Adds more tests.)

Change-Id: Ia7d25ba3995219ed6e686463dbba80c95cc831ca
6f94de3ca49e4ea147b1c59e5818fa175846518f 12-Feb-2013 Elliott Hughes <enh@google.com> Revert "More pthreads cleanup."

This reverts commit 2a1bb4e64677b9abbc17173c79768ed494565047

Change-Id: Ia443d0748015c8e9fc3121e40e68258616767b51
2a1bb4e64677b9abbc17173c79768ed494565047 11-Feb-2013 Elliott Hughes <enh@google.com> More pthreads cleanup.

POSIX says pthread_create returns EAGAIN, not ENOMEM.

Also pull pthread_attr_t functions into their own file.

Also pull pthread_setname_np into its own file.

Also remove unnecessary #includes from pthread_key.cpp.

Also account for those pthread keys used internally by bionic,
so they don't count against the number of keys available to user
code. (They do with glibc, but glibc's limit is the much more
generous 1024.)

Also factor out the common errno-restoring idiom to reduce gotos.

Bug: 6702535
Change-Id: I555e66efffcf2c1b5a2873569e91489156efca42