11859d467c035081f8acafeaf0184b670cd41c48 |
|
14-Feb-2017 |
Elliott Hughes <enh@google.com> |
Be more strict about using invalid `pthread_t`s. Another release, another attempt to remove the global thread list. But this time, let's admit that it's not going away. We can switch to using a read/write lock for the global thread list, and to aborting rather than quietly returning ESRCH if we're given an invalid pthread_t. This change affects pthread_detach, pthread_getcpuclockid, pthread_getschedparam/pthread_setschedparam, pthread_join, and pthread_kill: instead of returning ESRCH when passed an invalid pthread_t, if you're targeting O or above, they'll abort with the message "attempt to use invalid pthread_t". Note that this doesn't change behavior as much as you might think: the old lookup only held the global thread list lock for the duration of the lookup, so there was still a race between that and the dereference in the caller, given that callers actually need the tid to pass to some syscall or other, and sometimes update fields in the pthread_internal_t struct too. (This patch replaces such users with calls to pthread_gettid_np, which at least makes the TOCTOU window smaller.) We can't check thread->tid against 0 to see whether a pthread_t is still valid because a dead thread gets its thread struct unmapped along with its stack, so the dereference isn't safe. Taking the affected functions one by one: * pthread_getcpuclockid and pthread_getschedparam/pthread_setschedparam should be fine. Unsafe calls to those seem highly unlikely. * Unsafe pthread_detach callers probably want to switch to pthread_attr_setdetachstate instead, or using pthread_detach(pthread_self()) from the new thread's start routine rather than doing the detach in the parent. * pthread_join calls should be safe anyway, because a joinable thread won't actually exit and unmap until it's joined. If you're joining an unjoinable thread, the fix is to stop marking it detached. If you're joining an already-joined thread, you need to rethink your design. * Unsafe pthread_kill calls aren't portably fixable. (And are obviously inherently non-portable as-is.) The best alternative on Android is to use pthread_gettid_np at some point that you know the thread to be alive, and then call kill/tgkill directly. That's still not completely safe because if you're too late, the tid may have been reused, but then your code is inherently unsafe anyway. Bug: http://b/19636317 Test: ran tests Change-Id: I0372c4428e8a7f1c3af5c9334f5d9c25f2c73f21
|
7484c21c4c352a2200d94939fabc10d1bd3f0723 |
|
02-Feb-2017 |
Elliott Hughes <enh@google.com> |
Revert "Remove the global thread list." This reverts commit b0e8c565a622b5519e03d4416b0b5b1a5f20d7f5. Breaks swiftshader (http:/b/34883464). Change-Id: I7b21193ba8a78f07d7ac65e41d0fe8516940a83b
|
ea87716696bf635706b6f3fa56b8a145add83aff |
|
11-Jan-2017 |
Elliott Hughes <enh@google.com> |
localtime_r(3) should act as if it calls tzset(3). See code comment. Bug: http://b/31339449 Test: ran tests & benchmarks Change-Id: I6b6a63750ef41664dc4698207e6a53e77cc28cdf
|
b0e8c565a622b5519e03d4416b0b5b1a5f20d7f5 |
|
04-Jan-2017 |
Elliott Hughes <enh@google.com> |
Remove the global thread list. Another release, another attempt to fix this bug. This change affects pthread_detach, pthread_getcpuclockid, pthread_getschedparam/pthread_setschedparam, pthread_join, and pthread_kill: instead of returning ESRCH when passed an invalid pthread_t, they'll now SEGV. Note that this doesn't change behavior as much as you might think: the old lookup only held the global thread list lock for the duration of the lookup, so there was still a race between that and the dereference in the caller, given that callers actually need the tid to pass to some syscall or other, and sometimes update fields in the pthread_internal_t struct too. We can't check thread->tid against 0 to see whether a pthread_t is still valid because a dead thread gets its thread struct unmapped along with its stack, so the dereference isn't safe. Taking the affected functions one by one: * pthread_getcpuclockid and pthread_getschedparam/pthread_setschedparam should be fine. Unsafe calls to those seem highly unlikely. * Unsafe pthread_detach callers probably want to switch to pthread_attr_setdetachstate instead, or using pthread_detach(pthread_self()) from the new thread's start routine rather than doing the detach in the parent. * pthread_join calls should be safe anyway, because a joinable thread won't actually exit and unmap until it's joined. If you're joining an unjoinable thread, the fix is to stop marking it detached. If you're joining an already-joined thread, you need to rethink your design. * Unsafe pthread_kill calls aren't portably fixable. (And are obviously inherently non-portable as-is.) The best alternative on Android is to use pthread_gettid_np at some point that you know the thread to be alive, and then call kill/tgkill directly. That's still not completely safe because if you're too late, the tid may have been reused, but then your code is inherently unsafe anyway. If we find too much code is still broken, we can come back and disable the global thread list lookups for anything targeting >= O and then have another go at really removing this in P... Bug: http://b/19636317 Test: N6P boots, bionic tests pass Change-Id: Ia92641212f509344b99ee2a9bfab5383147fcba6
|
12443702c28bc589b39ff71c917beab600e03a13 |
|
20-Oct-2016 |
Elliott Hughes <enh@google.com> |
Add regression test for http://b/31938693. Bug: http://b/31938693 Bug: https://code.google.com/p/android/issues/detail?id=225132 Test: this is a test Change-Id: I858962a1dcd56d555a4836a7bfbdf92d5c3042f6
|
47126edb90126164ba001a5782c3cb11fdea0ca1 |
|
06-Sep-2016 |
Elliott Hughes <enh@google.com> |
Fix time.mktime_EOVERFLOW for LP32. Times before 1901-12-13 *underflow* on LP32, making the year 1900 a bad choice for success case. Bug: http://b/31305222 Change-Id: I20d4885c80b57707225580db044abc8948a55fdc
|
f8ebaa498562cfb199a9b28da5eae2770f9b3163 |
|
13-Aug-2016 |
Elliott Hughes <enh@google.com> |
Fix mktime's errno behavior. Don't touch errno on success, do set it to EOVERFLOW (the only allowed errno value according to POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/mktime.html) on failure. Bug: http://b/30477946 Change-Id: Ia915c7b9c3bfcd2f9025530cf5b068fe4dd4fd9e
|
0a610d00fee344f804d3338c880d73d2de5db143 |
|
29-Jul-2016 |
Elliott Hughes <enh@google.com> |
Upgrade to tzcode-2016f. No significant changes other than a default implementation of strftime_l. Change-Id: I6edd2c03e5e7559f012c0c87d43f7109d641d3ca
|
62e3a078aa7b156139b1a2cec77e1a84eb10c5a4 |
|
03-May-2016 |
Chih-Hung Hsieh <chh@google.com> |
Fix google-explicit-constructor warnings. Bug: 28341362 Change-Id: I84effbdfa1b9b39328a909b7f70fe17e7ee316c8
|
d15dfb2ff5835a04c66d328f27939fc4e0362c0f |
|
26-Mar-2016 |
Greg Hackmann <ghackmann@google.com> |
clock_nanosleep: add CLOCK_THREAD_CPUTIME_ID special case POSIX makes "the CPU-time clock of the calling thread" (i.e., CLOCK_THREAD_CPUTIME_ID) a special case which returns EINVAL instead of ENOTSUP. However, the clock_nanosleep syscall treats this clock just like any other, and returns -EOPNOTSUPP to indicate an unimplemented nanosleep handler. So we need to handle this ourselves in userspace. This change fixes the LTP clock_nanosleep01 testcase. Change-Id: If3bed940d276834bcd114d8c17f96197e9384711 Signed-off-by: Greg Hackmann <ghackmann@google.com>
|
43f7c875654cb94e589ff9d0c4ac58ca9616093e |
|
05-Feb-2016 |
Elliott Hughes <enh@google.com> |
Add a test for snprintf on a PTHREAD_STACK_MIN-sized stack. This is a common thing for people to want to do, snprintf requires a lot of stack for itself, and PTHREAD_STACK_MIN should be usable for realistic code. Change-Id: Ib09cfb4e0beec1c69ee0944c3ea4c5d03a94c491
|
33697a0c43c48e15c3bcf018138b9b837d0099cd |
|
26-Jan-2016 |
Elliott Hughes <enh@google.com> |
Factor out the waiting for children in bionic tests. Change-Id: I4a1e51b6920b33dc892d447f5bd6d10f1cb2704a
|
a9cac4c87a4ea3e6d1c0a1159909bf0e209a61a7 |
|
13-Nov-2015 |
Elliott Hughes <enh@google.com> |
Fix strftime if tm_zone is null. Upstream tzcode said "On platforms with tm_zone, strftime.c now assumes it is not NULL". Which is fine for any struct tm generated by tzcode, but not necessarily true of a struct tm constructed by arbitrary code. In particular, Netflix on Nexus Player was failing to start because they format "%Z" with a struct tm whose tm_zone is null (the other fields are valid, but, yeah, that's probably not intentional). glibc takes a null tm_zone to mean "the current time zone", so let's do that too. (Historically Android would use the empty string, and POSIX doesn't clarify which of this is the appropriate behavior when tm_zone is null.) Bug: http://b/25170306 Change-Id: Idbf68bfe90d143aca7dada8607742905188b1d33
|
bf572d91b50f818a7c3e29340cccf1931939ff8b |
|
11-Aug-2015 |
Yabin Cui <yabinc@google.com> |
Fix flaky test time.timer_settime_0. It fixes the problem reported in https://code.google.com/p/android/issues/detail?id=182395. Change-Id: Ie16aa04095dac08a62dd0d4c50e763b36526624c
|
d1ade7ce0237089d0e44eb2bee0691e4814d1289 |
|
19-Jun-2015 |
Yabin Cui <yabinc@google.com> |
Don't use TIMER_ABSTIME in time_test. If TIMER_ABSTIME is used in timer_settime(), the timer is always fired immediately, which is not the intent of the tests. Change-Id: I76047dbeb2bdded272ee6d028630b53bfd7d8514
|
410c1adf5fececb0149b7b65fde3130327ff24c8 |
|
19-Jun-2015 |
Yabin Cui <yabinc@google.com> |
Fix flaky test of timer_create_multiple in L. Bug: 20677618 Change-Id: I0cb5faf77edce042b10611543180f3e2e73d3d05
|
5c0996a96970eb7cf93d3203313a2532c119f1a7 |
|
08-May-2015 |
Yabin Cui <yabinc@google.com> |
Fix timer flaky test in lollipop-mr1-cts-dev. It is partically cherry-pick from https://android-review.googlesource.com/#/c/123410/. And as lollipop-mr1-cts-dev still uses stlport, <stdatomic.h> is used instead of <atomic>. Bug: 20677618 Change-Id: I952a6fd074facc4227c955fecf3ecbfbbaec4193
|
95f1ee235ae257802a94d7e94d476ea0aaea5cd8 |
|
14-Jan-2015 |
Yabin Cui <yabinc@google.com> |
Change on handling of SIGEV_THREAD timers. 1. Don't prevent calling callback when SIGEV_THREAD timers are disarmed by timer_settime. As in POSIX standard: The effect of disarming or resetting a timer with pending expiration notifications is unspecified. And glibc didn't prevent in this situation, so I think it is fine to remove the support. 2. Still prevent calling callback when SIGEV_THREAD timers are deleted by timer_delete. As in POSIX standard: The disposition of pending signals for the deleted timer is unspecified. However, glibc handles this (although that is not perfect). And some of our tests in time_test.cpp depend on this feature as described in b/18039727. so I retain the support. 3. Fix some flaky test in time_test.cpp, and make "time*" test pass on bionic-unit-tests-glibcxx. Bug: 18263854 Change-Id: I8ced184eacdbfcf433fd81b0c69c38824beb8ebc
|
4379016a20131740e25b33b2b09a2caef0aa62bd |
|
19-Feb-2015 |
Christopher Ferris <cferris@google.com> |
Revert "Modify test to avoid race condition." This reverts commit 3da136aa47e2d1608b98abb2580f024b36f92831. This change is not needed any where but lmp mr1. Change-Id: I3f38e2e8e418959a487bc0c4148d3238743e4626
|
3da136aa47e2d1608b98abb2580f024b36f92831 |
|
19-Feb-2015 |
Christopher Ferris <cferris@google.com> |
Modify test to avoid race condition. There is a possible race if a timer is set to trigger at nearly the same time as it is set. Since nobody uses the timers like this, modify the test so this doesn't happen. The race that this can provoke has been fixed in aosp. Bug: 19423618 Change-Id: I21084c99da5ae46f404936d673dae6bad7c82caa
|
d5c652756bb1a52959cd5c62447b62462f90f983 |
|
26-Nov-2014 |
Yabin Cui <yabinc@google.com> |
support _POSIX_CPUTIME Bug: 18490039 Change-Id: I01fa83b48e1b908de1f227b6e4f98e280bcd50ee
|
154e2026c83575eb17101df3a8d1192e305588d4 |
|
27-May-2014 |
Satoru Takeuchi <satoru.x.takeuchi@sonymobile.com> |
libc: Fix mktime returns an uncorrect time in empty TZ case The mktime API returned an uncorrect time when TZ is set as empty. A timezone UTC/GMT+0 should be implied in the empty case. However mktime keeps previous information about timezone. If mktime was called with a timezone which has DST before, the "defaulttype" member of "state" structure wouldn't be 0. Then it would be used next time, even though UTC/GMT+0 doesn't have DST. Added initialization of the "defaulttype" in the empty TZ case. Change-Id: Ic480c63c548c05444134e0aefb30a7b380e3f40b
|
62d84b19359a8ddd3df5b6293d1b05ef5281f532 |
|
21-Oct-2014 |
Christopher Ferris <cferris@google.com> |
Fix race condition in timer disarm/delete. When setting a repeat timer using the SIGEV_THREAD mechanism, it's possible that the callback can be called after the timer is disarmed or deleted. This happens because the kernel can generate signals that the timer thread will continue to handle even after the timer is supposed to be off. Add two new tests to verify that disarming/deleting doesn't continue to call the callback. Modify the repeat test to finish more quickly than before. Refactor the Counter implementation a bit. Bug: 18039727 (cherry pick from commit 0724132c3263145f2a667f453a199d313a5b3d9f) Change-Id: I135726ea4038a47920a6c511708813b1a9996c42
|
0724132c3263145f2a667f453a199d313a5b3d9f |
|
21-Oct-2014 |
Christopher Ferris <cferris@google.com> |
Fix race condition in timer disarm/delete. When setting a repeat timer using the SIGEV_THREAD mechanism, it's possible that the callback can be called after the timer is disarmed or deleted. This happens because the kernel can generate signals that the timer thread will continue to handle even after the timer is supposed to be off. Add two new tests to verify that disarming/deleting doesn't continue to call the callback. Modify the repeat test to finish more quickly than before. Refactor the Counter implementation a bit. Bug: 18039727 Change-Id: I73192c915cdacf608521b1792c54e5af14a34907
|
18160256840e9bb097f17422ea47d54fabbc9f3f |
|
12-Oct-2014 |
Haruki Hasegawa <h6a.h4i.0@gmail.com> |
Add clock_settime and clock_nanosleep. Add the missing prototypes, fix the existing prototypes to use clockid_t rather than int, fix clock_nanosleep's failure behavior, and add simple tests. Bug: 17644443 Bug: https://code.google.com/p/android/issues/detail?id=77372 Change-Id: I03fba369939403918abcabae9551a7123953d780 Signed-off-by: Haruki Hasegawa <h6a.h4i.0@gmail.com>
|
8d0b2dbf2154d5da17ff09b1d4f864d281362ad2 |
|
26-Sep-2014 |
Alex Van Brunt <avanbrunt@nvidia.com> |
Reimplement clock(3) using clock_gettime(3) Unlike times(), clock_gettime() is implemented as a vDSO on many architectures. So, using clock_gettime() will return a more accurate time and do so with less overhead because it does have the overhead of calling into the kernel. It is also significantly more accurate because it measures the actual time in nanoseconds rather than the number of ticks (typically 1 millisecond or more). Bug: 17814435 Change-Id: Id4945d9f387330518f78669809639952e9227ed9
|
04303f5a8ab9a992f3671d46b6ee2171582cbd61 |
|
19-Sep-2014 |
Elliott Hughes <enh@google.com> |
Add semaphore tests, fix sem_destroy. Bug: https://code.google.com/p/android/issues/detail?id=76088 Change-Id: I4a0561b23e90312384d40a1c804ca64ee98f4066
|
f4c948a9e9b616c4f133f9495dacb105e51b3e49 |
|
19-Aug-2014 |
Elliott Hughes <enh@google.com> |
Move the meat of <features.h> into <sys/cdefs.h>. This way it's a lot harder for us to screw up (since we should always be including <sys/cdefs.h> anyway). Bug: 14659579 Change-Id: I23070fff3296b0d1c683bb5e3a6e214146327d53
|
708c11205443cda14cfb21138d441106aa77a5f9 |
|
25-Jul-2014 |
Elliott Hughes <enh@google.com> |
Start hiding "private/bionic_time.h". Bug: 15765976 (cherry picked from commit 905e6d58aaf515bf237e62078f8a321920fe4c6b) Change-Id: Ic7435308e8b521886f42ac7bf59531924921ea67
|
905e6d58aaf515bf237e62078f8a321920fe4c6b |
|
25-Jul-2014 |
Elliott Hughes <enh@google.com> |
Start hiding "private/bionic_time.h". Bug: 15765976 Change-Id: Ibd9cf07067ec8dffe9fda6c3d498d4ab90708220
|
3002131da33401cf1b45abbdbec58b7c751fc43a |
|
16-Jul-2014 |
Elliott Hughes <enh@google.com> |
Use VDSO for clock_gettime(2) and gettimeofday(2). Bug: 15387103 (cherry picked from commit 625993dfbb085a3cde7492eda8ec1cdc1ee39a78) Change-Id: I0e156d7049ba1495902259071a96936592e74025
|
625993dfbb085a3cde7492eda8ec1cdc1ee39a78 |
|
16-Jul-2014 |
Elliott Hughes <enh@google.com> |
Use VDSO for clock_gettime(2) and gettimeofday(2). Bug: 15387103 Change-Id: Ifc3608ea65060c1dc38120b10b6e79874f182a36
|
7a39094465bbd01a22565fce1f1155c762f8d145 |
|
20-May-2014 |
Dan Albert <danalbert@google.com> |
Revert "Removes bionic's dependence on stlport" This reverts commit 4d35da1df8b74c1965b2201f6089e7d7bb352def. Change-Id: Ie9a2620441edb55dbc5949e13a4b913ea4e66797
|
4d35da1df8b74c1965b2201f6089e7d7bb352def |
|
19-May-2014 |
Dan Albert <danalbert@google.com> |
Removes bionic's dependence on stlport Only affects tests/benchmarks. Confirmed passing on arm. Change-Id: If158e23e8cd06e7597ef6f3c9376f6799b467e62
|
329103d3e2f42d3e35a060c3e0d326d6476eb2ef |
|
26-Apr-2014 |
Elliott Hughes <enh@google.com> |
Don't use so much stack in tzcode. Bug: 14313703 Bug: https://code.google.com/p/android/issues/detail?id=61130 Change-Id: Id9b240fce20d4a6f2660792070e02b2b5f287655
|
efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4 |
|
08-Apr-2014 |
Elliott Hughes <enh@google.com> |
Remove a non-standard turd: strtotimeval. Change-Id: I1b1e40746cb573e3fb73a5276969b40c5da36d15
|
4bfaf462f0c864473faaca63cc4ba9e1a1b103a8 |
|
26-Mar-2014 |
Calin Juravle <calin@google.com> |
Added strtotimeval tests. Change-Id: I3dfd3647a8494490a2d549bdb915968063a7fb99
|
753ad778bc1c3aecc4cd82b8387a7dc8a9b44d34 |
|
21-Mar-2014 |
Christopher Ferris <cferris@google.com> |
Fix deadlock in timer_delete. If the callback function for a timer did a timer_delete, the function would never return. The problem was that the timer_delete function would try to wait until the timer thread has finished. Waiting for yourself to finish doesn't work very well. Bug: 13397340 Change-Id: Ica123a5bafbc8660c8a4a909e5c2dead55ca429d
|
3e3409af0faa8843078a9e6e7110e69a88210da4 |
|
11-Mar-2014 |
Elliott Hughes <enh@google.com> |
Add system/extras strftime and strptime tests. Change-Id: I889c58f6e2e27b99cf6328a8671858d2e5feaa4e
|
be1d91dedcfb346ced5ac496cd454f5b2e9bc4a9 |
|
09-Mar-2014 |
Brian Carlstrom <bdc@google.com> |
Add includes for waitpid (cherry picked from commit f07c5dd9ab63f2e8ba736107bd4b69bbd8829c9f) Change-Id: I7a765fd7a3a5f8f29a703f6a591c4fd8df4ebf1c
|
4b558f50a42c97d461f1dede5aaaae490ea99e2e |
|
05-Mar-2014 |
Elliott Hughes <enh@google.com> |
Rewrite the POSIX timer functions. 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
|
f04935c85e0b466f0d30d2cd4c0fa2fff62e7d6d |
|
21-Dec-2013 |
Christopher Ferris <cferris@google.com> |
Make sure that the same tests are on all platforms. 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
|
0c40152767188dc718a46e5b4e7e32e937c85bd8 |
|
19-Oct-2013 |
Elliott Hughes <enh@google.com> |
Fix the time unit tests for systems with 64-bit time_t. Change-Id: I29df50b25d022c1c00906e71b612defa58e46e81
|
f0c10a4a16c74f5099cf6b272c0a2f11f454e63c |
|
22-Aug-2013 |
Elliott Hughes <enh@google.com> |
Work around tzcode's reliance on signed overflow. I've mailed the tz list about this, and will switch to whatever upstream fix comes along as soon as it's available. Bug: 10310929 (cherry picked from commit 7843d44a594270bcb56e98b130603c054f8a9d38) Change-Id: I205e2440703444c50cecd91d3458d33613ddbc59
|
7843d44a594270bcb56e98b130603c054f8a9d38 |
|
22-Aug-2013 |
Elliott Hughes <enh@google.com> |
Work around tzcode's reliance on signed overflow. I've mailed the tz list about this, and will switch to whatever upstream fix comes along as soon as it's available. Bug: 10310929 Change-Id: I36bf3fcf11f5ac9b88137597bac3487a7bb81b0f
|
ee178bfb794d16d6c5a35f424b28c8ebb83e1581 |
|
12-Jul-2013 |
Elliott Hughes <enh@google.com> |
Add a trivial gmtime(3) test. Change-Id: I849f200a455cd6971646fa45766ab22ba19fb866
|
744df77d4730cff99ac36f9761153620105dd9d7 |
|
14-Mar-2013 |
Elliott Hughes <enh@google.com> |
am 2e7b8d63: am f861bc5c: Merge "Don\'t search off the end of the index for bad Olson ids." * commit '2e7b8d6399fdea6e43dd07f353346324d2bf4ec4': Don't search off the end of the index for bad Olson ids.
|
e0175ca7e440a87e9d03f249fc8f210063df7908 |
|
14-Mar-2013 |
Elliott Hughes <enh@google.com> |
Don't search off the end of the index for bad Olson ids. In the old code, the index was a file to itself, so it made sense to read until you hit the end of the file. In the new code, the index is followed by hundreds of KiB of data, so we need to just search the index. Bug: 8368791 Change-Id: Icf5f8b5516cf3a93679fa849c9f6cd1cb100e0f1
|