Commit graph

8225 commits

Author SHA1 Message Date
Christopher Ferris
c0352bbd5f Add offset to backtrace_string printing.
The libmemunreachable code uses backtrace_string to print out the backtrace
information. However, when the offset of the map that a frame is in is
non-zero, no information is printed. This means that when a frame comes from
a shared library loaded from an apk, it's impossible to tell which
shared library the frame is really coming from.

Add the offset display when it's non-zero. This means this can now be fed
to development/scripts/stack to decode the frame.

Bug: 37276041

Test: Ran dumpsys meminfo --unreachable on an app that leaks from a
Test: shared library and verified the offset output is present.
Change-Id: I61d34ae3f617622d354cc099eff520a64782b6e2
2017-05-25 18:38:45 -07:00
Christopher Ferris
a559cff654 Merge "Update malloc debug documentation." 2017-05-26 00:30:01 +00:00
Christopher Ferris
4c65669ab7 Update malloc debug documentation.
Test: NA
Change-Id: I8ab73bfc28c7a673efb5b0cec6067989153f092a
2017-05-25 17:23:08 -07:00
Treehugger Robot
025fb33c9d Merge "Remove the repetitive warnings from the uapi headers." 2017-05-25 22:50:06 +00:00
Elliott Hughes
96c1db7b9d Remove the repetitive warnings from the uapi headers.
Having

  WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS

every four lines made the headers harder to read, made the diffs much worse
each time we upgraded, and wasn't really providing any benefit. Before the
next uapi update, let's just stop doing this.

Bug: N/A
Test: builds, manually inspected files look right
Change-Id: Id7088cf750894c9d24950f3d53587fe3156c4f7d
2017-05-25 13:48:01 -07:00
Treehugger Robot
f58179cda5 Merge "Stop including <sys/sysmacros.h> from <sys/types.h>." 2017-05-25 01:43:07 +00:00
Christopher Ferris
866e7b6906 Fix assembler warnings.
There are a few instructions deprecated on armv8 that result in lots
of warnings. Add an arch directive so that these warnings go away.

This doesn't cause any problems because the instructions still
execute properly.

Bug: 38319728

Test: Built all of these assembler files and verified the warning are gone.
Change-Id: If063defdd16f290c01975233c8d257d1b2005e76
2017-05-24 16:06:11 -07:00
Elliott Hughes
6c01208e90 Merge "Remove obsolete __stack_chk_fail_local." 2017-05-24 15:05:59 +00:00
Treehugger Robot
1f66c6d078 Merge "Fix _POSIX_THREAD_PROCESS_SHARED." 2017-05-24 07:13:36 +00:00
Elliott Hughes
4af220cfef Remove obsolete __stack_chk_fail_local.
Clang doesn't use this.

Bug: N/A
Test: x86 emulator builds and boots
Change-Id: I2865c0d568a644f61f34bdea539daff5224896bc
2017-05-23 16:43:30 -07:00
Elliott Hughes
81a5b6f558 Merge "Switch to inline assembler in crtbegin." 2017-05-23 23:40:00 +00:00
Elliott Hughes
8543f923fe Stop including <sys/sysmacros.h> from <sys/types.h>.
<sys/types.h> unconditionally includes <sys/sysmacros.h>.

<sys/sysmacros.h> defines major, minor, and makedev. In the deprecated NDK
headers, these were inline functions. In the unified headers, they are
function-like macros.

The inline functions would only collide with another function called major,
minor, or makedev but the macros will replace anything with a function-like
form such as definitions of class methods called major, minor, or makedev.
This causes code which has such definitions to fail to compile when moving
from the deprecated headers to the unified headers.

Resolve this by removing the transitive dependency. Folks who want
<sys/sysmacros.h> can ask for it explicitly (it's been in both bionic and
glibc for years, though I don't think macOS has it [as usual]).

Bug: https://github.com/android-ndk/ndk/issues/398
Test: builds
Change-Id: If2921c7b5d979c3066f199f22c64d4d2f7bf6632
2017-05-23 15:53:36 -07:00
Elliott Hughes
94072fbb4e Switch to inline assembler in crtbegin.
Using __builtin_frame_address was clever, but didn't work for arm64 (for
reasons which were never investigated) and the ChromeOS folks claim it
causes trouble for x86 with ARC++ (though without a reproduceable test case).

Naked functions turn out to be quite unevenly supported: some architectures
do the right thing, others don't; some architectures warn, others don't (and
the warnings don't always match the platforms that _actually_ have problems).

Inline assembler also removes the guessing games: everyone knows what the
couple of instructions _ought_ to be, and now we don't have to reason about
what the compiler will actually do (yet still keep the majority of the code
in C).

Bug: N/A
Test: builds, boots
Change-Id: I14207ef50ca46b6eca273c3cb7509c311146a3ca
2017-05-23 14:47:16 -07:00
Treehugger Robot
dc18a4be63 Merge "Make use of the DNS query hook in the netcontext" 2017-05-23 13:17:43 +00:00
Treehugger Robot
7bbe7cb619 Merge changes Iefdc1662,I8ee9ce62
* changes:
  Don't define IN_CLOEXEC/IN_NONBLOCK for pre-L.
  Undef EPOLL_CLOEXEC for pre-L.
2017-05-23 00:48:01 +00:00
Ben Schwartz
90a83beb4d Make use of the DNS query hook in the netcontext
This will allow netd to run queries over TLS:
https://android-review.googlesource.com/#/c/391513/
https://android-review.googlesource.com/#/c/380593/

Bug: 34953048
Test: Device tests pass.  No issues during manual testing.
Change-Id: I8d613322307fc40cdba59b82599eda753697278f
2017-05-22 18:37:25 -04:00
Dan Albert
5a215d7817 Don't define IN_CLOEXEC/IN_NONBLOCK for pre-L.
Some third-party code uses the existence of IN_CLOEXEC/IN_NONBLOCK to
detect the availability of inotify_init1. This is not correct, since
`syscall(__NR_inotify_init1, IN_CLOEXEC)` is still valid even if the C
library doesn't have that function, but for the time being we don't
want to harm adoption to the unified headers. We'll avoid defining
IN_CLOEXEC and IN_NONBLOCK if we don't have inotify_init1 for the time
being, and maybe revisit this later.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/394
Change-Id: Iefdc1662b21045de886c7ad1cbeba6241163d943
2017-05-22 12:58:18 -07:00
Dan Albert
cdfface662 Undef EPOLL_CLOEXEC for pre-L.
Some third-party code uses the existence of EPOLL_CLOEXEC to detect
the availability of epoll_create1. This is not correct, since having
up-to-date UAPI headers says nothing about the C library, but for the
time being we don't want to harm adoption to the unified headers.
We'll undef EPOLL_CLOEXEC if we don't have epoll_create1 for the time
being, and maybe revisit this later.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/302
Bug: https://github.com/android-ndk/ndk/issues/394
Change-Id: I8ee9ce62768fb174070ec51d114f477389befc4a
2017-05-22 12:52:00 -07:00
Ben Schwartz
dd878fe129 Add a netcontext variant of gethostbyname
Bug: 34953048
Test: Integration tests pass
Change-Id: I670427d67fde09d8e76ea6a920c90a1969230c4f
2017-05-22 10:19:25 -04:00
Treehugger Robot
4767bc4a6c Merge "Add a netcontext variant of gethostbyaddr" 2017-05-22 10:06:31 +00:00
Treehugger Robot
761bb2be4d Merge "Add the DNS query hook to net context" 2017-05-22 02:51:36 +00:00
Treehugger Robot
137a2cf967 Merge "Va_end should be used with va_start" 2017-05-20 22:08:12 +00:00
Mikhail Lappo
13ec1cf3da Va_end should be used with va_start
va_start is used and va_end should
be invoked accordingly

Change-Id: I2b0a2af762e22082a351a4d8139aaa48bc791e88
2017-05-20 13:20:41 -07:00
Elliott Hughes
468c8086e6 Fix _POSIX_THREAD_PROCESS_SHARED.
We've had pthread_*_setpshared for long enough that there are no
__INTRODUCED_IN guards.

Found because fio's configure script was confused by this.

Bug: N/A
Test: ran tests
Change-Id: I07b4d937741e4dcd7e615f2371b17c827341917a
2017-05-20 13:11:14 -07:00
Christopher Ferris
2b0f2a4855 Fix missing function export.
Bug: 36401135

Test: Actually enable debug malloc and verify it loads properly.
Test: Ran unit tests.
Change-Id: I9df1699b06bb14c5df2c3cab35dc2eb0819033f1
2017-05-19 13:47:16 -07:00
Elliott Hughes
8fbd15a6d0 Merge "Make union semun usable." 2017-05-19 18:24:09 +00:00
Elliott Hughes
497ad30d7d Make union semun usable.
This is a bit bogus because it's been removed from glibc (though not
thoroughly) and is never useful on Android (because the system calls
in question are compiled out of Android kernels, and SELinux would
disallow them even if you weren't running an Android kernel). This
also means that on glibc you need to include <linux/sem.h> for this
and on bionic you need <sys/sem.h> (and for either if you #include
the other file, you won't get this union).

Bug: https://github.com/android-ndk/ndk/issues/400
Test: added new test
Change-Id: I47f721da77515531f616d6ad8479bfbc9b60ee47
2017-05-18 15:05:26 -07:00
Ben Schwartz
50178056f7 Add a netcontext variant of gethostbyaddr
Bug: 34953048
Test: Integration tests pass
Change-Id: Id04830345be56cd7a077981c6e2acfb5568e7a88
2017-05-18 14:32:21 -04:00
Ben Schwartz
f0305dcee9 Add the DNS query hook to net context
This change
 - adds a query hook to android_net_context
 - exposes relevant definitions to netd
 - corrects a bug in query hooks' interaction with the cache

This change does not introduce any code to read the query hook
from the net context or make use of it.

Bug: 34953048
Test: Netd test suite passes
Change-Id: Ie091980e22ce9da07a3c4d387b371e544379d762
2017-05-18 12:03:11 -04:00
Christopher Ferris
083923d96a Make mallopt available in the future.
I made this in 26 but it's really only available in the future.

Test: Built angler image.
Change-Id: I9e1179b350103bf1b8774459a9e210b377300d40
2017-05-17 14:48:59 -07:00
Christopher Ferris
6fba793bc3 Merge "libc: ARM64: fix memset for non-standard ZVA sizes" 2017-05-16 20:07:21 +00:00
Christopher Ferris
d84c30ddec Merge "Add support for modifying decay timer." 2017-05-16 14:02:53 +00:00
Kevin Brodsky
f19eeb8446 libc: ARM64: fix memset for non-standard ZVA sizes
372f19e9e2 ("libc: ARM64: update memset/strlen/memcpy/memmove to
newlib/cortex-strings") introduced a bug in memset, only occurring
on the [set_long + zero + non-standard ZVA size] path, more
specifically when DCZID_EL0 reports a size different to 64 or 128.

On platforms with such sizes reported by DCZID_EL0, various string*
unit tests fail due to memset zeroing memory before and/or after the
area it is supposed to set.

Test: bionic-unit-tests --gtest_filter=string*
Change-Id: Idb80c0269226e40e343645a58608e3f324378468
2017-05-16 11:29:49 +01:00
Christopher Ferris
a1c0d2fd4c Add support for modifying decay timer.
Add the mallopt function, and only a single option so far.

Bug: 36401135

Test: Built and booted bullhead.
Test: Ran jemalloc unit tests.
Test: Ran bionic unit tests.
Test: Ran a test that allocated and free'd a large piece of memory,
Test: and verified that after changing the parameter, the PSS
Test: sticks around (decay timer set to 1), the PSS is purged (decay
Test: timer set to 0).
Change-Id: I6927929b0c539c1023d34772d9e26bb6a8a45877
2017-05-15 16:59:16 -07:00
Christopher Ferris
94bd274551 Add support for cortex-a73.
Bug: 37647380

Test: Built target with cortex-a73 for both 32 bit/64 bit.
Test: Built target with cortex-a53.cortex-a57 for both 32 bit/64 bit.
Test: Ran bionic unit tests, ran art target tests.

(cherry picked from commit 6fca047b53)

Change-Id: I2c48e1bc7f4a3c4548d1c66f87eab19c8618a0b8
2017-05-15 12:44:58 -07:00
Treehugger Robot
d785b4465e Merge "Clean up __isthreaded." 2017-05-12 01:35:51 +00:00
Elliott Hughes
dfcb82d92d Clean up __isthreaded.
__isthreaded is annoying for ARC++ and useless for everyone. Just hard-code
the value in ndk_cruft for LP32 and be done with it.

Bug: N/A
Test: builds
Change-Id: I08f11a404bbec55ed57cb1e18b5116163c7d7d13
2017-05-11 15:29:03 -07:00
Elliott Hughes
a57476b661 Run bionic/libc/tools/genversion-scripts.py
When 2e8e5e60b6 was cherrypicked, we
didn't regenerate the generated files.

Bug: N/A
Test: builds
Change-Id: I87730e834520aea742738708237d11a798bf3220
2017-05-11 15:14:41 -07:00
Treehugger Robot
3c71e1ae18 Merge "Cope with AT_SYSINFO not being set on x86." 2017-05-10 01:28:55 +00:00
Elliott Hughes
b291d08af2 Zero-initialize user_desc for __set_thread_area.
The kernel does seem to read some of the "unused" fields if only to do
basic validity checks.

valgrind complained about this, and I'm not convinced it's spurious.

Bug: http://b/38034461
Test: ran tests
Change-Id: I077fcc75bf0738491242166fc4576a9693ce18a5
2017-05-09 14:39:24 -07:00
Elliott Hughes
9ae23720aa Cope with AT_SYSINFO not being set on x86.
Bug: http://b/38034461
Test: ran dexdump under valgrind on x86
Change-Id: I6a54c7ed4fe4e68731e099d9569ab788379820f8
2017-05-09 14:26:30 -07:00
Treehugger Robot
1f9e648878 Merge "Make raise/abort work with stale cached pid/tid values." 2017-05-06 00:56:21 +00:00
Josh Gao
bf2af69fb2 Make raise/abort work with stale cached pid/tid values.
Switch raise to using tgkill with direct syscalls of getpid/gettid,
and switch abort to use raise(SIGABRT).

Bug: http://b/37769298
Test: debuggerd_test
Change-Id: If6f9d17fd8ae6177e742dc9f2f44bd78539431ba
2017-05-05 14:25:24 -07:00
Lazar Trsic
dd5bd456fb [MIPS64] Enable necessary mips64 syscalls in seccomp whitelist
Allow execution of: newfstatat, fstat and cacheflush syscalls
for mips64 arch.

Test: Boot mips64 emulator to homescreen with 3.18 kernel.
emulator -kernel prebuilts/qemu-kernel/mips64/3.18/kernel-qemu2

Change-Id: Ib5d6b0060f3e17b64d86fc944aa83a5240d512f8
2017-05-05 15:37:11 +02:00
Lazar Trsic
22b4351d5e Fix MIPS seccomp definitions for PRIMARY and SECONDARY arch
Set correct values for PRIMARY and SECONDARY arch definitions
to match LE MIPS architectures.
This change is resolving boot problem for mips32 arch with 3.18 kernel.
This also fixes mips64 issue related to PRIMARY_ARCH definition,
but in order to boot to home screen it needs additional syscalls whitelisted
which will be introduced in separate patch.

Tested on emulator:
emulator -kernel prebuilts/qemu-kernel/mips/3.18/kernel-qemu2

Change-Id: I68dfd136c22141933a8a8c5336db01a02f00b0df
2017-05-05 15:27:58 +02:00
Jake Weinstein
28285f5338 libc: clean up ARM64 copyright notices
Test: None needed

Change-Id: I3626a92329e954f67bada6ed73f3033225bbfef5
2017-05-04 12:59:53 -04:00
Christopher Ferris
7a3681e5b6 Move libc_log code into libasync_safe.
This library is used by a number of different libraries in the system.
Make it easy for platform libraries to use this library and create
an actual exported include file.

Change the names of the functions to reflect the new name of the library.

Run clang_format on the async_safe_log.cpp file since the formatting is
all over the place.

Bug: 31919199

Test: Compiled for angler/bullhead, and booted.
Test: Ran bionic unit tests.
Test: Ran the malloc debug tests.
Change-Id: I8071bf690c17b0ea3bc8dc5749cdd5b6ad58478a
2017-05-03 08:50:43 -07:00
Elliott Hughes
d390df1dbc Restore ELF32_ST_INFO/ELF64_ST_INFO.
Mistakenly removed years ago, along with its genuinely duplicated companions.
This patch also redefines one of those rather than use the Linux uapi header
definition, which leads to signed/unsigned warnings in calling code.

Bug: https://github.com/android-ndk/ndk/issues/377
Test: ran tests
Change-Id: Ib25b17949f04969f12b945ca88ab87d080677cf9
2017-04-30 22:56:10 -07:00
Elliott Hughes
2fad0d5927 Include the libc/kernel/android/scsi headers in the NDK.
We have some non-upstream (but Android common kernel) scsi headers to include
in the NDK.

Bug: N/A
Test: checked out/soong/ndk/sysroot
Change-Id: If7611e1e554ada63f266ec99d95dfedb99562ae9
2017-04-27 16:26:55 -07:00
Yi Kong
82f7208ac0 Merge "Update bionic after Clang rebase" 2017-04-26 23:00:41 +00:00