Commit graph

27775 commits

Author SHA1 Message Date
Christopher Ferris
6cf828c310 Merge "Avoid heapprofd init when other hooks enabled." 2019-02-15 01:43:19 +00:00
Iris Chang
b34415046c malloc debug: fix LogFreeError error log
When free_track option is enabled and malloc debug detects error in
VerifyFreedPointer flow, if freed pointer's usable_size is more than
g_debug->config().fill_on_free_bytes(), the error log is not correct.

The max. bytes printed to error message should be the max bytes to
cmp, not usable size.

Bug: 124420174
Test: build pass and test pass
Change-Id: I41f35ab3330e49e0a6ad276d405bf4f6c3f0ea92
2019-02-14 17:15:03 -08:00
Dan Albert
30a0bf0aec Remove removed functions from symbol_ordering.
Test: treehugger
Bug: None
Change-Id: Id398f8d5b3d8a6f9acc25cf222ba8c963e4a6341
2019-02-14 14:52:41 -08:00
Elliott Hughes
3019d78d4a libasync_safe: stop clobbering other folks' identifiers.
The log priorities and ids are in an NDK header, available to everyone.

Move CHECK into its own header for now. This would be better if it was
more like the <android-base/logging.h> CHECK family, but I don't have an
easy way to do that without lots of copy & paste, so punting for now.

Bug: https://issuetracker.google.com/issues/119713191
Test: boots
Change-Id: I4566be8a0a024fede0e2d257c98b908ec67af2a8
2019-02-14 14:23:13 -08:00
Pirama Arumuga Nainar
fcd35380dd Disable native_coverage for ld-android and linker
Bug: http://b/116873221

The coverage library, which depends on libc, cannot link with libraries
since they opt of libc.

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=bionic
Change-Id: Iaaca8bc30c8ba59e5d4f7092b1a0fce8e8c14c72
2019-02-14 13:50:55 -08:00
Christopher Ferris
2822856e98 Avoid heapprofd init when other hooks enabled.
All of the heapprofd code assumes that it's the only hook that
has been enabled. Enforce that by disallowing heapprofd from
enabling if malloc debug or malloc hooks have been enabled.

Test: Ran all unit tests (bionic/malloc hooks/malloc debug/perfetto).
Test: Enabled malloc debug ran perfetto integration tests and verified
Test: that an error message goes to the log.
Change-Id: I506fbf1c5b8e4052855531fa0d161f5de06e6c1a
2019-02-14 10:23:58 -08:00
Treehugger Robot
1b82812635 Merge "Fix hwasan build." 2019-02-14 08:04:46 +00:00
Christopher Ferris
883144719a Fix hwasan build.
Test: hwasan builds properly.
Change-Id: I3c911da08d1925b797423671e3beb72770a934b0
2019-02-13 22:15:28 -08:00
Treehugger Robot
1462d267e2 Merge "Symbols files under $(OUT)/symbols/bionic/" 2019-02-14 05:27:44 +00:00
Pirama Arumuga Nainar
bd912d2868 Merge "Disable native_coverage for libdl" 2019-02-14 00:05:57 +00:00
Treehugger Robot
b5c1b12389 Merge "Sync with upstream NetBSD." 2019-02-14 00:04:20 +00:00
Elliott Hughes
4fc93ffa62 Sync with upstream NetBSD.
Bug: http://b/123359356
Test: treehugger
Change-Id: Ide95d7eeb24cc0e22914162be423f8bacfdd3548
2019-02-13 14:17:18 -08:00
Treehugger Robot
0197b0a92f Merge "Use no_libcrt property instead of hard coding projects to exclude" 2019-02-13 21:53:26 +00:00
Christopher Ferris
c2136b51aa Merge "Refactor malloc common into distinct pieces." 2019-02-13 18:38:22 +00:00
Victor Chang
af12c94e79 Redirect /system/lib/libicuuc.so regardless of duplication in /system
The change is a workaround of app compat issue until the app fixes the
issue.

Likely, the app does not only dlopen(), but open() the libicuuc.so
with the absolute path.

Note that platform uses the stub libandroidicu.so, not libicuuc directly.
This CL topic moves (not duplicates) libandroidicu from /system to
/apex. Even though /system/lib/libicuuc.so is kept in the default
namespace, but no one should be using it.

Some debug info after this CL:
$ adb shell cat /proc/<zygote pid>/maps | grep libicuuc
$ adb shell cat /proc/<app pid>/maps | grep libicuuc
Only /apex/com.android.runtime/lib64/libicuuc.so is found, not the
/system.

Bug: 124218500
Test: The app can be launched successfully
Test: CtsJniTestCases
Change-Id: I67a50f0ad934be567a63d4038215546c9b4e5f7e
2019-02-13 15:31:06 +00:00
Ryan Prichard
40f18976db Merge "Only test tprel_missing_weak in dynamic binaries" 2019-02-13 00:26:51 +00:00
Christopher Ferris
e4cdbc4754 Refactor malloc common into distinct pieces.
The pieces:
- The malloc common shared by static and dynamic code (malloc_common.cpp).
- The code for shared libraries that includes any dlopen'ing
  (malloc_common_dynamic.cpp).
- The implementation of perfetto's heapprofd (malloc_heapprofd.cpp).

This makes it easier to see what's going on in the many different areas.
It should also make it easier to add the allocation capping option.

Other related changes:
- Update the unit tests for android_mallopt. All of the current options
  don't work on static binaries, so make sure that is reflected in the test.
- A few names changes to make sure that all code is consistent.

Test: Ran tests (malloc hooks/malloc debug/perfetto/bionic unit tests).
Change-Id: I0893bfbc0f83d82506fac5d1f37cf92fbdef6f59
2019-02-12 14:19:07 -08:00
Yi Kong
16f947281f Use no_libcrt property instead of hard coding projects to exclude
Test: m checkbuild
Change-Id: If34c72d37dc4077ca3e83135391256bc53d295b5
2019-02-12 09:49:23 -08:00
Elliott Hughes
c682e3b6e5 Merge "Greylist libraries are attempted to be loaded in the default ns" 2019-02-12 16:48:13 +00:00
Jiyong Park
efc503d677 Greylist libraries are attempted to be loaded in the default ns
Some of the greylist libraries can be in directories other than
/system/lib. For example, libnativehelper.so is moved from the directory
to /apex/com.android.runtime/lib.

Previous behavior for greylist libraries is to find the lib under
/system/lib while "within" the current namespace which is usually the
classloader-namespace. Since the libs no longer exist there, linker
fails to load it and no further attempt is made.

This change fixes the problem by loading the greylist libs "from" the
default namespace. Since there is a link from the default namespace to
the namespace where the moved libraries are intended to be loaded (e.g.,
the 'runtime' namespace for libnativehelper.so), the call is successful.

Bug: 124201397
Test: bionic-unit-tests

Change-Id: I11d15993d18896bdf663c408f9e40d8a607c9b80
2019-02-12 23:07:08 +09:00
Ryan Prichard
7fda2c9495 Only test tprel_missing_weak in dynamic binaries
Rename a test to be less confusing when this file tests unresolved weaks
with both TPREL and TLSDESC relocations.

Bug: http://b/123635978
Test: bionic unit tests
Change-Id: Id17d76a41159d134d16e84a699cc284662eb99bb
2019-02-11 18:37:17 -08:00
Jiyong Park
acb4d21a2a Symbols files under $(OUT)/symbols/bionic/
We need symbol files for /bionic/* paths.

New property "mountsource" is added to specify the "real" module that
the bionic mountpoint module is a mountpoint for. The real module
provides path to the unstripped elf file, which is installed to the
symbols/bionic/* path.

Bug: 123985838
Test: m libc.mountpoint libm.mountpoint libdl.mountpoint
linker.mountpoint
$(OUT)/symbols/bionic/bin/linker, bionic/lib[64]/lib{c|dl|m}.so exist

Change-Id: I43f074f0076b576f214fe92a98689a413efd3daa
2019-02-11 16:05:48 +09:00
Sandeep Patil
7d2aea09dd bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile
Bug: 123532375
Test: Builds

Change-Id: I8e782d9050b4d6a0726e8c880d4064df99c763e5
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-02-10 17:27:39 -08:00
android-build-team Robot
d307fa248c Snap for 5180536 from b32be3f072 to pi-platform-release
Change-Id: I75a97c71db475898cbe477b3048846574a89f97a
2019-02-09 02:35:59 +00:00
Ryan Prichard
808d176e7e Merge "Fix linker self-exec detection" 2019-02-08 22:33:11 +00:00
Ryan Prichard
1990ba5601 Fix linker self-exec detection
When the linker is invoked on itself, (`linker64 /system/bin/linker64`),
the linker prints an error, because self-invocation isn't allowed. The
current method for detecting self-invocation fails because the second
linker instance can crash in a constructor function before reaching
__linker_init.

Fix the problem by moving the error check into a constructor function,
which finishes initializing libc sufficiently to call async_safe_fatal.
The only important thing missing is __libc_sysinfo on 32-bit x86. The aux
vector isn't readily accessible, so use the fallback int 0x80.

Bug: http://b/123637025
Test: bionic unit tests (32-bit x86)
Change-Id: I8be6369e8be3938906628ae1f82be13e6c510119
2019-02-07 21:48:42 -08:00
Christopher Ferris
2eb1fc9df0 Merge "Fix flakiness of mallinfo test." 2019-02-08 00:36:14 +00:00
Christopher Ferris
15a345b789 Merge "Modify malloc common function pointers." 2019-02-08 00:02:40 +00:00
Christopher Ferris
62e1e2c7e3 Modify malloc common function pointers.
Instead of every function being its own atomic, have a single
pointer that can be used to flip all pointers at once. This avoid cases
where the set of pointers can be in an partial switched state.

Also fix a few inconsistent naming of functions in the file.

Test: Ran unit tests (malloc debug, malloc hooks, perfetto).
Change-Id: I3f66da395414586a3fa87874d80dcdf5f702ed39
Merged-In: I3f66da395414586a3fa87874d80dcdf5f702ed39
(cherry picked from commit 77184aedaf)
2019-02-07 14:48:34 -08:00
Pirama Arumuga Nainar
852d5230e2 Disable native_coverage for libdl
Bug: http://b/116873221
Bug: http://b/124067925

If not,
https://android-review.googlesource.com/c/platform/build/soong/+/848621
breaks blueline_coverage-userdebug target in internal branches with the
following error:
    build/make/core/base_rules.mk:290: error: bionic/libdl:
    MODULE.TARGET.SHARED_LIBRARIES.libdl already defined by
    bionic/libdl.

Test: build blueline_coverage-userdebug in internal branch.

Change-Id: I8fff866ae2e17ce6daa4d8c75c72ceb17e2e73de
2019-02-07 14:28:29 -08:00
Christopher Ferris
4e56228637 Fix flakiness of mallinfo test.
The test was really only supposed to verify that mallinfo eventually
increase after allocations of certain sizes. Sometimes the mallinfo
returned decreases due to some compaction event, so don't fail in that
case.

Bug: 124060188

Test: Ran the test 2000 times (32 bit and 64 bit). It would fail within about
Test: 200 test iterations before.
Change-Id: Ie019107be163dcf275cedf4d1bc5759278def483
2019-02-07 14:20:03 -08:00
vichang
1d3c56bc30 Merge "Revert "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""" 2019-02-07 12:28:00 +00:00
Treehugger Robot
5569bc7d34 Merge "Eliminate ICU's .dat lookup from bionic" 2019-02-07 10:21:06 +00:00
Victor Chang
6cb719f0ed Revert "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""
This reverts commit 1906e77665
and fixes dlopen(nullptr)

It's enabled for the following .so libraries
libicuuc.so
libicui18n.so

This CL does not move the .so files into a APEX.
Thus, no visible effect before moving .so files.

Bug: 121248172
Test: dlfcn#dlopen_from_nullptr
Test: Perform the following test after moving libicuuc to /apex
      dlopen("/system/lib64/libicuuc.so") for targetSdkVersion < Q
Change-Id: Ia310ea566485fe00ca28e2203f4bffbd92243638
2019-02-07 01:17:37 +00:00
Evgenii Stepanov
f827d82cdd Merge "Cleanup bionic tests with hwasan." 2019-02-06 22:04:09 +00:00
Evgenii Stepanov
7cc6706370 Cleanup bionic tests with hwasan.
The tests were patched earlier to run with tagging heap allocator.
This change enables hwasan code instrumentation in the tests themselves,
and fixes the issues that arise, mainly in the code that:
* compares addresses of unrelated stack variables
* compares address of a stack variable with stack limits as found in
  /proc/self/maps
* writes address of a stack variable to a hardware watchpoint register
etc.

Note that static tests are broken at the moment, like all static
binaries. Dynamic tests pass 100% with this change.

Bug: 114279110, 124007027
Test: SANITIZE_TARGET=hwaddress; run dynamic bionic tests

Change-Id: I68b8df9dd3e30b47734ddc083811a75a7f27deaa
2019-02-06 13:59:16 -08:00
Nikita Iashchenko
45f2d03ae5 Eliminate ICU's .dat lookup from bionic
Before this CL bionic did the following:

 * Finds the ICU .dat file with scandir()
 * Extracts the ICU version number from the file name. e.g. _63
 * dlopen() libicuuc
 * dlsym() necessary symbols, e.g. <symbol name>_<icu version>

Right now such ICU symbols are stored in libandroidicu.so and suffixed
with "_android", so it is responsible for "redirecting" to functions
with approriate version and we do not need to lookup the version on our
own. libicuuc is still available for NDK (and apps), and libandroidicu is
a subset of libicuuc and libicui18n.

After this CL bionic will do the following:

 * dlopen() libandroiicu
 * dlsym() <symbol_name>_android (without specific version suffix)

Bug: 122822987
Test: cts-tradefed run cts-dev -m CtsBionicTestCases
Change-Id: Iabd9f35b9c3462739fd2b18e60dcdc3e202031ac
2019-02-06 20:49:03 +00:00
vichang
73ee7a6320 Merge "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q"" 2019-02-06 17:03:41 +00:00
Treehugger Robot
3f8bdb216c Merge "Fix use-after-pthread_exit in a test." 2019-02-06 16:42:47 +00:00
vichang
1906e77665 Revert "Allow dlopen("/system/lib/<soname>") for pre-Q"
This reverts commit f6e4cfd933.

Reason for revert: b/123972211

Change-Id: I1ea199c27e224bbd27dee7692f9f448ca9c2b6d1
2019-02-06 16:42:21 +00:00
Elliott Hughes
9a5c0fc9d3 Merge "Switch to OpenBSD div/ldiv/lldiv." 2019-02-06 16:40:21 +00:00
Elliott Hughes
166dfd6f49 Merge "Avoid writing to a zero-capacity buffer." 2019-02-06 16:39:33 +00:00
Evgenii Stepanov
352853a535 Fix use-after-pthread_exit in a test.
HWASan reports access to a local variable after the owning thread has
called pthread_exit.

Bug: 114279110
Test: enable hwasan in tests/Android.bp; run pthread_DeathTest.pthread_bug_37410
Change-Id: Ic04a2b3dce092d7ab3cbefab1da64731e0c7afb9
2019-02-05 17:37:37 -08:00
Elliott Hughes
01809e1fd1 Switch to OpenBSD div/ldiv/lldiv.
Test: ran tests
Change-Id: I6ecf5878162d7cee81af40edd4b44406196f49be
2019-02-05 16:48:22 -08:00
Elliott Hughes
e7c5954b31 Merge "Move NetBSD string routines to OpenBSD." 2019-02-06 00:37:48 +00:00
Elliott Hughes
288465d6e9 Avoid writing to a zero-capacity buffer.
Bug: http://b/120752721
Test: ran tests
Change-Id: I3f03ae204ab5de40fd4402a5562c50ffe51ef998
2019-02-05 15:00:13 -08:00
Elliott Hughes
fbac97a54c Move NetBSD string routines to OpenBSD.
NetBSD seems to be the least well maintained of our three BSD upstreams,
and it's already the one we use the least. Let's push a little further
in that direction...

Test: new smoke tests
Change-Id: Idfebd11794445fe14cbfa07177a7392a7b36a5e4
2019-02-05 12:15:27 -08:00
vichang
9c48951a7d Merge "Allow dlopen("/system/lib/<soname>") for pre-Q" 2019-02-05 12:34:00 +00:00
Elliott Hughes
5c45c4efb2 Merge "libm: sync with upstream FreeBSD." 2019-02-05 00:04:53 +00:00
Victor Chang
f6e4cfd933 Allow dlopen("/system/lib/<soname>") for pre-Q
It's enabled for the following .so libraries
libicuuc.so
libicui18n.so

This CL does not move the .so files into a APEX.
Thus, no visible effect before moving .so files.

Bug: 121248172
Test: Perform the following test after moving libicuuc to /apex
      dlopen("/system/lib64/libicuuc.so") for targetSdkVersion < Q
Change-Id: Ic00d281d59de924c01582c48d2a946e3f5f33a09
2019-02-04 23:45:19 +00:00