Commit graph

885 commits

Author SHA1 Message Date
Zhi Dou
7099a138bc Merge "Replace "apex_inherit" min_sdk_version" 2022-12-20 15:50:13 +00:00
Zhi Dou
ab9b5df4b8 Replace "apex_inherit" min_sdk_version
Replace "apex_inherit" min_sdk_version to a conditional setting. If
environment veriable KEEP_APEX_INHERIT is set, using "apex_inherit" as
the min_sdk_version, otherwise set the number to "29". For more detail
please refer
https://docs.google.com/document/d/1R2vZw0cQa-haAMgFyQ682uSq9aGBNQrzMHKIsU17-XY/edit?usp=sharing&resourcekey=0-gUbs463r9LCKs7vdP_Xkmg

Test: build APEX uses this library, and presubmit
Bug: 254634795
Ignore-AOSP-First: Need to submit with other changes.
Change-Id: Ie6984128e6b84ba73de3f4c08eca5560657c5ca2
2022-12-09 22:36:28 +00:00
Hsin-Yi Chen
20d45cc9ce Merge "Add an ABI dump directory for libutils" 2022-12-09 01:57:43 +00:00
Hsin-Yi Chen
3de02bd0d5 Add an ABI dump directory for libutils
The ABI dumps add visibility for API changes in a commonly used library.

Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py \
      -libs libutils -products aosp_arm64 \
      -ref-dump-dir system/core/libutils/abi-dumps
Test: m libutils.vendor
Bug: 227282691
Change-Id: I498c62853562a8fc6702bdd622603b6f7d516274
2022-12-08 11:06:22 +08:00
Eric Miao
c2527073c2 libutils: Add more tests for Unicode
This CL added additional tests for converting between utf16 and utf8,
specifically tests that:

  1. check utf16_to_utf8_length() returns 0 if input is an
     empty UTF16 string

  2. check utf16_to_utf8_length() returns 1 if input is a
     single ASCII character UTF16 string

  3. check utf16_to_utf8_length() returns 3 if input is a
     single UTF-16 character between U+0800 - U+FFFF

  4. check utf16_to_utf8_length() returns 4 if input has
     a surrogate pair

  5. check unpaired UTF-16 surrogate is handled correctly
     (skipped)

  6. check utf16_to_utf8_length(0 handles invalid surrogate
     case correctly, by skipping the first but handling the
     rest correctly

  7. check a normal string with a mix of 1/2/3/4-byte UTF8
     characters is correctly converted by utf16_to_utf8()

  8. check conversion from invalid utf8 sequence with invalid
     leading byte and/or invalid trailing byte(s) should still
     work and not crash

Change-Id: If68e514af0e84ddebf5900b2e140e76ba4f44553
2022-12-06 15:14:27 -08:00
Treehugger Robot
660d08e08e Merge "libutils: Fix missing definition of shared_ptr and unique_ptr" am: dfdcc31d03 am: 11c22fcc00 am: fc262c5d1b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2318113

Change-Id: I17bdc15fbb557e87702fe0ac7653a0cd7a076959
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-29 03:19:22 +00:00
Biswapriyo Nath
890f064990 libutils: Fix missing definition of shared_ptr and unique_ptr
This includes memory header for shared_ptr and unique_ptr templates.
Fixes the following errors:

RefBase.h:803:1: error: ‘shared_ptr’ does not name a type
RefBase.h:810:1: error: ‘unique_ptr’ does not name a type

Change-Id: I6a7a67333c9ef05250c5a3c6199d7fac288f946b
2022-11-25 12:15:53 +05:30
Treehugger Robot
7bf2643d7b Merge "libutils: Include limits for std::numeric_limits::max" am: 202a688068 am: 8613027b33 am: afd814764f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2264883

Change-Id: I63363a378aa1d5f7e10b8ba839bbf9c826b36d57
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-21 19:19:31 +00:00
Biswapriyo Nath
9e25bf0136 libutils: Include limits for std::numeric_limits::max
This fixes the following error:
core/libutils/String8.cpp:316:67: error: incomplete type 'std::numeric_limits<long long unsigned int>' used in nested name specifier
  316 |         if (static_cast<size_t>(n) > std::numeric_limits<size_t>::max() - 1 ||
      |                                                                   ^~~

Change-Id: I80cdd2442e2798c37e066e3fdeee7dd5ac34b669
2022-10-21 10:26:08 +05:30
Steven Moreland
3258da7e60 Merge changes I732e5b8a,I4271909e am: b9d8e8289e am: 73d171ff83 am: bebd9adca0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2243559

Change-Id: I61fe3ab6f483db28c3b3a2690c0c65bdb30e3af8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-10 22:14:26 +00:00
Steven Moreland
b7412c8cd6 libutils: RefBase DEBUG_REF love
Done here:
- path saved to a useable location on host
- path always printed (for visibility for new users)
- open(.., 666) - That's '01204' not '0644' oops

Future considerations:
- make defines constexpr instead of ifdef
- copy malloc hook design to avoid needing to recompile code
- make libutilscallstack default on host
- run libutils tests, not just test compile debug mode
- code incorrectly prints ref 'doesn't exist'
  seems it's gotten out of sync, but still good enough
  to use stacktraces

Bug: 244325464
Test: manual
Change-Id: I732e5b8aec3cd946ef3559a2a814caf693846cc0
2022-10-10 16:58:57 +00:00
Steven Moreland
377adea81c libutils: DEBUG_* modes compile forever
I've seen these fixed before, so we compile the debug modes
now.

Bug: 244325464
Test: 'm libutils_test_compile'
Change-Id: I4271909e81893ad448bc46b8a3a567a84c40f8a3
2022-10-08 05:13:47 +00:00
Treehugger Robot
2fe4b1350a Merge "Fix the build with a newer LLVM." am: eed5e27c24 am: dcd275b3f8 am: 2d68f08f16 am: ec5c419332 am: 907559c144
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2214887

Change-Id: I136900db1e0c35c97eec5df9fd45e41757a62a09
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-15 03:55:50 +00:00
Elliott Hughes
b795d6fa4b Fix the build with a newer LLVM.
Unify all our "noinline" variants to the current most common one, not
least because the new [[noinline]] syntax is fussier about where it goes.

Test: treehugger
Change-Id: Icfcb75c9d687f0f05c19f66ee778fd8962519436
2022-09-14 20:16:25 +00:00
Christopher Ferris
9ff15d78f5 Merge "Fix thread unwind in CallStack." am: 16909c5fc7 am: 4cea1cd5ce am: 05009ec97a am: 34194c8de6 am: 63fa82da36
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2215567

Change-Id: I6d78e228c7b3af25989e523b7882ad48cbd7787e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-13 23:34:42 +00:00
Christopher Ferris
15fee82247 Fix thread unwind in CallStack.
The CallStack unwind of a different thread was broken since it
wasn't properly setting the tid value.

Fix this problem and add new unit tests to verify the behavior.

Bug: 246405269

Test: New unit tests pass.
Test: Ran unit tests for 1000 operations to verify not flaky.
Change-Id: I00342e6cdcdb4bcb68f29734dadee6c987c98040
2022-09-12 18:37:22 -07:00
Ryan Prichard
09e47607d5 Merge "Remove unnecessary std::unary_function base classes" am: 1ff7e26b2c am: d346a0d0cc am: 201cad7fca am: 88b734e239 am: 764e5cf2d6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2199557

Change-Id: I56ab81a5c1af43037585741e25517a1fe3a70d32
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-29 22:50:23 +00:00
Ryan Prichard
4913ca88e5 Remove unnecessary std::unary_function base classes
The function objects work equally well without them, and the base
classes were wrong for both types:
 * HashForEntry: returns size_t but declared to return hash_t
   (uint32_t)
 * EqualityForHashedEntries: returns bool and takes two parameters but
   declared to return hash_t and take one parameter

std::unary_function was deprecated in C++11 and removed in C++17.
Upstream libc++ now removes the type for new-enough C++ dialects.

Bug: http://b/175635923
Test: treehugger
Change-Id: I2ff15c5da6a4e4f71df08c243f8af2f11d8d2b0d
2022-08-26 20:24:57 -07:00
Steven Moreland
c73c453065 Merge "RefBase: test for stack check" am: 5daa3bb90e am: 643d08e706 am: fcd246e6f3 am: f0ce53c05a am: b0d45e6491
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2169132

Change-Id: Ia6c6306498abcf24c10d248ac6e838382434fcad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 20:02:47 +00:00
Steven Moreland
643d08e706 Merge "RefBase: test for stack check" am: 5daa3bb90e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2169132

Change-Id: Ib7b35af8469fdc563244f2dde4a4e0ee91e7f35a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 18:31:32 +00:00
Steven Moreland
5daa3bb90e Merge "RefBase: test for stack check" 2022-07-29 18:10:03 +00:00
Steven Moreland
2dcd08af3d Merge "libutils: disallow extending lifetime on stack" am: ea25b4ba5b am: c55c68fe33 am: bc43001408 am: 74218da6b4 am: 34737da2d3
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166445

Change-Id: Idbc42ed35fe09202daa54b7768a6b12bbc05c3f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 01:12:12 +00:00
Steven Moreland
cd4ef87efd RefBase: test for stack check
Surprised this isn't breaking anything, so wanted to
make sure it worked.

Bug: 232557259
Test: libutils_test
Change-Id: Iaec47d644c02dc190e397c6f84dcfab4cc76f566
2022-07-29 00:54:57 +00:00
Steven Moreland
c55c68fe33 Merge "libutils: disallow extending lifetime on stack" am: ea25b4ba5b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166445

Change-Id: I48eb86eb8426b1e5c7c92f957173b2eb63870864
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-28 23:45:34 +00:00
Steven Moreland
ea25b4ba5b Merge "libutils: disallow extending lifetime on stack" 2022-07-28 23:17:35 +00:00
Steven Moreland
ed1e93432e Merge "libutils: RefBase always disallow on stack" am: 51e98b8378 am: de52706513 am: cf323aa232 am: 812ffe2426 am: dbd566ccb0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166102

Change-Id: If730d484842d81650003ca4a04e8a888ca805e87
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-28 18:22:29 +00:00
Steven Moreland
de52706513 Merge "libutils: RefBase always disallow on stack" am: 51e98b8378
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166102

Change-Id: Ia8b3205fbb6e36b3c85a378df4c63db4f32759f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-28 16:29:49 +00:00
Steven Moreland
51e98b8378 Merge "libutils: RefBase always disallow on stack" 2022-07-28 16:11:10 +00:00
Steven Moreland
96bf1a34dd Merge "libutils: RefBase: extra check for double own" am: b0fe01da56 am: 414bab91eb am: 1908c24773 am: 5448e26c6e am: 5074f0a45e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166103

Change-Id: I0d41f2b0ff656f689bf563d5f40e720c65f5a5b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-26 23:04:01 +00:00
Steven Moreland
414bab91eb Merge "libutils: RefBase: extra check for double own" am: b0fe01da56
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2166103

Change-Id: Ie252e8a229d8151aad82347f6b216dbed752d86b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-26 22:27:26 +00:00
Steven Moreland
d086fe5109 libutils: disallow extending lifetime on stack
Bug: 232557259
Test: libutils_test
Change-Id: Iacf45b9f295a48904606ced35994ba35566bfcc3
2022-07-26 22:11:13 +00:00
Steven Moreland
c340a08b1b libutils: RefBase always disallow on stack
Before, we only did this in sp<> constructors, but we can always make
this check during the initial incStrong.

Since prebuilts call into the existing report race function declared
in StrongPointer.h, we still call this function from RefBase.cpp.

Bug: 232557259
Test: libutils_test
Change-Id: I4080b1869b83ecf655fc9c182b6de768a6358adf
2022-07-26 22:10:51 +00:00
Steven Moreland
483a2def8d libutils: RefBase: extra check for double own
Bug: 232557259
Test: libutils_test
Change-Id: Ibd400750e7973600ec3fa493838a3b52cafe3add
2022-07-26 17:59:14 +00:00
Xin Li
ebe6598a1c Merge tm-dev-plus-aosp-without-vendor@8763363
Bug: 236760014
Merged-In: Ia927c19f544536f78c20ccef5830bd1be0cebf9b
Change-Id: I0267b9eaad470a56db68f3a0b99abfc41192c6d7
2022-06-28 21:23:43 +00:00
Steven Moreland
58a8a95abd Merge "RefBase: disallow make_shared, make_unique" am: 1cdb22fb05 am: 9709f5503f am: 5261b4fbd0 am: 9fb56016a4 am: a52f9317c9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2098087

Change-Id: I955fe782d5749cccfc22c01c3282178efc3fad65
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-27 20:51:59 +00:00
Steven Moreland
5261b4fbd0 Merge "RefBase: disallow make_shared, make_unique" am: 1cdb22fb05 am: 9709f5503f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2098087

Change-Id: I8e2d57ad7ff3a8231b4fe1aea252c46b96ff379f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-27 18:53:00 +00:00
Steven Moreland
9d8af6af65 RefBase: disallow make_shared, make_unique
It's risky to mix multiple-ownership types. Taken from SharedRefBase.

Bug: 232557259
Test: N/A
Change-Id: Ic0dbd6d11e44fa9db87c4f9b1776d4989cbf9f56
2022-06-22 21:54:43 +00:00
Hsin-Yi Chen
d82bd5a626 RESTRICT AUTOMERGE Ignore weak symbol difference in libutils ABI check am: c7d9320ca4
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/18603830

Change-Id: Ia15131ac6bb49823df032e39a8ee81e5d332addb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-27 03:18:38 +00:00
Hsin-Yi Chen
c7d9320ca4 RESTRICT AUTOMERGE Ignore weak symbol difference in libutils ABI check
The diff_flags make the ABI checker ignore the weak symbol difference
caused by PGO.

Ignore-AOSP-First: This patch relaxes the ABI check for T only.
                   b/232982219 tracks the long-term solution.
Test: make libutils.vendor
Bug: 230076879
Change-Id: I8ec2c0f5a540263b4e8a0a4f9cf26f9c297593b5
2022-05-26 15:20:06 +08:00
Treehugger Robot
e7da3eb805 Merge "Doc Thread requirement." am: c545516e2c am: 40ce64b6db
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2094349

Change-Id: I95cebb43fcd70803fe0bdece39d57546053264cb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 03:21:16 +00:00
Treehugger Robot
c545516e2c Merge "Doc Thread requirement." 2022-05-12 01:53:32 +00:00
Christopher Ferris
39819bbc94 Merge "Use the new AndroidUnwinder object." am: af4db6749a am: ce1c33332c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095264

Change-Id: Icc76b39136bce395106c070aeb338d4e6922a28e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 00:32:48 +00:00
Steven Moreland
90722d254e Doc Thread requirement.
Fixes: 230893354
Test: N/A
Change-Id: I426184840c7bf61fe3369388cfc6db184470acf0
2022-05-11 23:13:17 +00:00
Christopher Ferris
ab63124cd9 Use the new AndroidUnwinder object.
Replaces libbacktrace in CallStack. There is one small behavioral
change, the BuildId data is added to the unwinds.

Bug: 120606663

Test: All unit tests pass.
Test: Run the fuzzer for over an hour without any crashes.
Change-Id: Ic8a4247c515ce0d3cdc4d2cc15167d1948b15fa5
2022-05-10 17:19:12 -07:00
Elliott Hughes
5affe3efe2 Merge "libutils: clearer abort on overflow." am: 4ba0e62970 am: 2c623bc650
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2078005

Change-Id: I150014b6afda9aff751383c5b5b6ff2934ec7400
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-28 01:15:58 +00:00
Elliott Hughes
b10bf63c93 libutils: clearer abort on overflow.
Let's turn a bug into a feature... Since this code is built with intsan,
anyone who caused overflow here will have had an abort, so we know
no-one actually needs the BAD_INDEX return that was presumably the
original author's intent. So let's just mandate that, since it's a lot
harder to ignore an abort than it is to ignore an error return.

Bug: http://b/179044558
Test: treehugger
Change-Id: I08f1018f9da1e09de885699138b7543d55bb2a36
(cherry picked from commit a5f2e4d421)
Merged-In: I08f1018f9da1e09de885699138b7543d55bb2a36
2022-04-28 00:25:25 +00:00
Elliott Hughes
a5f2e4d421 libutils: clearer abort on overflow.
Let's turn a bug into a feature... Since this code is built with intsan,
anyone who caused overflow here will have had an abort, so we know
no-one actually needs the BAD_INDEX return that was presumably the
original author's intent. So let's just mandate that, since it's a lot
harder to ignore an abort than it is to ignore an error return.

Bug: http://b/179044558
Test: treehugger
Change-Id: I08f1018f9da1e09de885699138b7543d55bb2a36
2022-04-27 14:29:44 -07:00
Steven Moreland
6a1358236e Merge "Mark libutilscallstack min sdk version." am: f5ca027819 am: d94c71f4fb am: 83441e640e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2061788

Change-Id: I0675d8f86306e73c977b8eed9adb513d902ce684
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-12 18:54:48 +00:00
Steven Moreland
6c509ca3c3 Mark libutilscallstack min sdk version.
Mark this as 29 for easy inclusion in APEXes when debugging. Make
sure we don't introduce calls to things here which would prevent
this from being used on old platforms.

Fixes: 228561718
Test: build
Change-Id: I2574455dbfe681117e4afcf6eef3546be51393fa
2022-04-11 22:30:07 +00:00
Florian Mayer
2b393f3664 Merge "Make callback outlive LruCache." am: 6948bbf62c am: 9e67f9302c am: 877cd36104
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2052189

Change-Id: Ibe676c9758cb914098ea775e05d8f468c0a564e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 01:20:50 +00:00