This is a patch testing whether we can use abort() instead of
returning ESRCH for invalid pthread ids. It is an intermediate
step to remove g_thread_list/g_thread_list_lock.
Bug: 19636317
Change-Id: Idd8e4a346c7ce91e1be0c2ebcb78ce51c0d0a31d
If pthread_detach() is called while the thread is in pthread_exit(),
it takes the risk that no one can free the pthread_internal_t.
So I add PTHREAD_ATTR_FLAG_ZOMBIE to detect this, maybe very rare, but
both glibc and netbsd libpthread have similar function.
Change-Id: Iaa15f651903b8ca07aaa7bd4de46ff14a2f93835
Executing test via test_forked() allows us to
avoid undesired global state changes in tests like
atexit, dlopen(.., RTLD_NODELETE) and similar.
Change-Id: I118cdf009269ab5dd7b117c9b61dafa47de2a011
This catches one trivial difference between us and glibc --- the error
returned by pthread_setname_np for an invalid pthread_t.
Change-Id: If4c21e22107c6488333d11184f8005f8669096c2
Migrate the test about pthread mutex type in file
system/extras/tests/bionic/libc/bionic/test_mutex.c
to the new place
bionic/tests/pthread_test.cpp
in the gtest format.
Change-Id: I6aab10170ccad5b9a4892d52dba2403876c86659
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
The previous pthread_key_create_many test was really
pthread_key_create_all, which has proven very difficult to test
correctly (because it is affected by any other parts of the system using
pthread keys, and that can vary with test ordering). It also tested
expected values of PTHREAD_KEYS_MAX and the associated sysconf() value,
rather than those being in their own test.
Instead, split this test into a few distinct tests:
* pthread.pthread_keys_max
* pthread._SC_THREAD_KEYS_MAX_big_enough_for_POSIX
* pthread.pthread_key_many_distinct
* We actually didn't have a test to ensure that the keys we were
creating were distinct.
* pthread.pthread_key_EAGAIN
* Make sure pthread_key_create() will _eventually_ fail with
EAGAIN, not at a (sometimes incorrectly) predetermined maximum.
Change-Id: Iff1e4fdcc02404094bde0418122c64c227cf1702
Enable the -std=gnu++11 flag for libstdc++ static and
dynamic libs.
ScopeGuard uses DISABLE_ macros instead of '= delete';
Change-Id: I07e21b306f95fffd49345f7fa136cfdac61e0225
There were two problems here:
* This would fail when run with unlimited stack, because it didn't know
that bionic reports unlimited stacks as 8MiB.
* This would leave RLIMIT_STACK small, causing failures to exec (so the
popen and system tests would fail).
Change-Id: I5b92dc64ca089400223b2d9a3743e9b9d57c1bc2
...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
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
During pthread_exit, the keys are cleaned. Unfortunately, a call to
free occurs after the cleanup and the memory for some of the keys
is recreated when using jemalloc. The solution is to do the key
cleanup twice.
Also, modify the pthread_detach__leak test to be less flaky
when run on a jemalloc system.
Bug: 16513133
(cherry picked from commit 18d93f2793)
Change-Id: Idb32e7f9b09e2c088d256ed9eb881df80c81ff8e
- used underscore_style_for_vars
- extracted time related functionality into a function
- cleaned up style
- removed unused fields from pthread_rwlock_t on LP64
- changed reservation in pthread_rwlock_t so that the size of the
structure equals glibc version
Bug: 8133149
Change-Id: I84ad3918678dc7f5e6b3db9b7e9b0899d3abe9cd
clone(2) is the public symbol.
Also switch a test from __bionic_clone to clone; testing public API
means the test now works on glibc too.
Change-Id: If59def26a00c3afadb8a6cf9442094c35a59ffde
This is a much simpler implementation that lets the kernel
do as much as possible.
Co-authored-by: Jörgen Strand <jorgen.strand@sonymobile.com>
Co-authored-by: Snild Dolkow <snild.dolkow@sonymobile.com>
Change-Id: Iad19f155de977667aea09410266d54e63e8a26bf
This replaces the non-standard pthread_mutex_lock_timeout_np, which we have
to keep around on LP32 for binary compatibility.
Change-Id: I098dc7cd38369f0c1bec1fac35687fbd27392e00
We only support CLOCK_REALTIME and CLOCK_MONOTONIC for now,
so we us a single bit from pthread_cond_t->value to denote
the clock type. Note that this reduces the width of the counter
to 30 bits, but this should be large enough for all practical
purposes.
bug: 13232338
Change-Id: I857e7da64b3ecbb23eeac7c9f3fbd460f60231bd
In order to be able to generate a list of tests for cts, the same set of
tests must exist across all platforms. This CL adds empty tests where a
test was conditionally compiled out.
This CL creates a single library libBionicTests that includes all of
the tests found in bionic-unit-tests-static.
Also fix a few missing include files in some test files.
Tested by running and compiling the tests for every platform and
verifying the same number of tests are on each platform.
Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
__bionic_clone modifies the child stack before cloning so the stack
pointer should be valid. The test is expecting an EINVAL error to be
generated from the incorrect flags: CLONE_THREAD set without
CLONE_SIGHAND.
Change-Id: Ic02192081f6f52df6f03d9810efa82d923247a11