The code was using an off64_t but calling mmap. This caused the code
to abort on 32 bit.
Add a unit test that would abort on the previous version.
Bug: 155662887
Test: New unit test passes.
Change-Id: I7a6efbc0d4227403c3d08a08deea56f239382157
Merged-In: I7a6efbc0d4227403c3d08a08deea56f239382157
(cherry picked from commit 7b9f35c9de)
The code was using an off64_t but calling mmap. This caused the code
to abort on 32 bit.
Add a unit test that would abort on the previous version.
Bug: 155662887
Test: New unit test passes.
Change-Id: I7a6efbc0d4227403c3d08a08deea56f239382157
const parameters can't be moved but only get copied -
removed const
Bug: 153704006
Test: builds & boots
Change-Id: If7e2250325bf1bc498afd3539f60bcb075a1d43b
The marked library(ies) were available to the APEXes via the hand-written
whitelist in build/soong/apex/apex.go. Trying to remove the whitelist
by adding apex_available property to the Android.bp of the libraries.
In this change, following libs were made available to all apexes because
their usage is quite common and there is no reason to restrict them
to some APEXes.
* libbase_headers
* libcutils, libcutils_headers
* libutils_headers, libsystem_headers
* liblog_headers
* libbacktrace, libbacktrace_headers
* libcrypto_utils
Exempt-From-Owner-Approval: cherry-pick from aosp
Bug: 150999716
Test: m
Merged-In: If3d3652e6604ed4f6d7694fe7ac61ae496621026
(cherry picked from commit 8bf9b1632e)
Change-Id: If3d3652e6604ed4f6d7694fe7ac61ae496621026
The marked library(ies) were available to the APEXes via the hand-written
whitelist in build/soong/apex/apex.go. Trying to remove the whitelist
by adding apex_available property to the Android.bp of the libraries.
In this change, following libs were made available to all apexes because
their usage is quite common and there is no reason to restrict them
to some APEXes.
* libbase_headers
* libcutils, libcutils_headers
* libutils_headers, libsystem_headers
* liblog_headers
* libbacktrace, libbacktrace_headers
* libcrypto_utils
Bug: 150999716
Test: m
Change-Id: If3d3652e6604ed4f6d7694fe7ac61ae496621026
This is in preparation of doing what we did for SharedRefBase (hiding
operator new) so that clients can't accidentally construct
shared_ptr/unique_ptr or any other alternative memory management scheme
which would conflict with RefBase. You can see what ultimately happened
to SharedRefBase in frameworks/native CL
10d9ddf2e3da3ba3a425fb8396aaaec728e5fbdb.
The goal for this:
- promote use of 'sp<T>::make' over 'sp<T> .. = new T'
- make 'operator new' a private member of RefBase
Bug: 138956784
Test: libutils_test
Change-Id: I47f4d28edbf7534730c7b6fb1de748dd60f34e11
Before, this was printing the pointer to the char16_t* because of an
automatic conversion. However, this is almost never intended.
Bug: N/A
Test: dumpsys_test
Change-Id: Iaafcb2145cf93028cf3271813c56b8b74948f943
If a thread priority is greater than or equal to
ANDROID_PRIORITY_BACKGROUND, and the new priority is less than
ANDROID_PRIORITY_BACKGROUND, set the sched policy to its parent process.
Bug: 139521784
Test: functionality verified
Change-Id: Ie6fe33e08e4fda0a119b9869e8dd1733c164d79e
Perhaps the better question is, why have I 100s of times, typed
"ASSERT_NE(nullptr, foo)" for sp<> foo, and got a compiler error and
then change it to "foo.get()". This CL so we can stop wasting cycles
with that error.
Fixes: 147842528
Test: libutils_test
Change-Id: Id63b29d2a1ff3077201a62b69d864c5a826c47e0
For clarity, when printint w/o delination, noticed in b/145776393.
Test: view output of statusToString from a dumpsys change
Change-Id: I5ea9f052c223f167dd58923e2470c852907c97b8
For the raw pointer constructor, check that the argument is not on the
stack. Passing a stack pointer as an sp<> parameter is dangerous,
since we will attempt to deallocate the object once the sp<> is no
longer needed. We approximate ste stack ccheck by testing whether it
is on the same page as the frame pointer.
Do the same for raw pointer assignment.
Bug: 138956784
Test: Boot AOSP
Change-Id: I2c2405be443389af7e6a713aadcb3ee1f372a85e
For libbinder, not having these statuses printed out causes never ending
problems for developers.
Bug: 144534032
Test: libhidl_test tests this, which is on TH here
Change-Id: I02f37fb1e5b743131598ddc95ef89ebdfbdff615
Bug: 141890807
Test: boot, check data is zero'd
Change-Id: I45aaeac369f4c5cf3eb44f61c233e00f870a5c79
(cherry picked from commit bf824f8fa5)
(cherry picked from commit e62a9d7669)
Imagine an AIDL file:
package android.foo;
interface IFoo {}
The AIDL C++ backend will generate classes like "::android::foo::IFoo".
In order to avoid ODR conflict, the NDK (Stable C) backend linking
against libbinder_ndk puts everything under the "::aidl" namespace. So,
we have "::aidl::android::foo::IFoo". When using ScopedTrace in a class
implementing a class from this backend, there is this problem.
Bug: 141828236
Test: works
Change-Id: Iafadea11788d4c011229657b4f53063bcf65f8d8
This class isn't used very much and it isn't supported by AIDL. In order
to recommend new users against this and recommend an alternative, added
a comment here.
Bug: 142282873
Test: N/A
Change-Id: If7c6c9fac6c868ed6a515e658de752092d25d5f9
Newly allocated SharedBuffer already has reference count 1, so we
should not call acquire().
Bug: 141764153
Test: Run String16Test.* with ASan that was able to detect the leak
without this change.
Change-Id: Ib8b1b707b028386d717414d8c5ec5ea7b4b59464
libcutils has trace implemented for host. In order to increase code
portability, opening that up for libutils Trace.h usage as well.
Bug: 124524556
Test: use Trace.h on host glinux
Change-Id: Ia873f88e7436a18f6c0f761000bf697c68ffea17
The Android framework, notably android.view.Choreographer, assumes
that System.nanoTime and SystemClock.uptimeMills return consistent
values. This was true on device, but not on host.
This commit makes those values consistent on host linux. The necessary
support should be in place in kernels 2.6.39 and newer, which have been
available since 2012.
Test: m -j libutils
Change-Id: I833a89a810ae9fb3e8c01f6095ee2aca893c284f
25 -> 100, because we are seeing larger values sometimes on cuttlefish.
Fixes: 141212746
Test: libutils_test
Change-Id: I371416473b97f46891104ff9d893ec38c25728aa
This reverts commit 1270e4fbf1.
Bug: 138856262
Test: Run unit tests.
Change-Id: I37be01d7d4f98a83078870cb0917275336fa2bbd
Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
This time with old branches excluded.
Bug: 138856262
Test: Run unit tests.
Change-Id: Id0bb1d54b71e38244d64f1b684db1fda81de854c
Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
This is a backward compatible implementation of compile time
constructed String16 support.
As much as we'd like a regular constexpr constructor for String16, we
want to make sure the regular non-static String16 does not regress.
We also need to make sure prebuilts built with previous version of
String16 still works with new libutils. This means we cannot change
the size of String16 objects and we cannot make anything virtual.
To add a flag to indicate whether a String16 is static without
increasing the size of non-static String16 objects, we repurpose a
reserved field in SharedBuffer as "for client use". With this, we can
tag every String16 and perform memory operation differently based on
how the underlying buffers are allocated.
By using StaticString16, we are able to eliminate the runtime
construction of a String16 and move it out of .bss section.
Bug: 138856262
Test: Run newly added unit tests.
Change-Id: I72bb8dc27a59b9ef34e0d934bc1e00b0f675855a
printWeakPointer isn't implemented anywhere. This also allows us to
remove a forward declaration of TextOutput.
Bug: N/A
Test: N/A
Change-Id: Ie2debdfda17b7cc1d599c431eaf4c362a591e482
Android build system added support for building translated binaries
used on natively bridged targets (arm on x86 for example).
However in order to avoid building unnecessary binaries and libraries
for such architectures most modules do not support native bridge by default.
All needed modules have to explicitly indicate if they may be used as part
of translated binary build.
This change enabled native bridge support for libutils which is a
greylisted library (available for apps targeting Android version < N).
Bug: http://b/77159578
Test: make
Change-Id: I58667558d2a673fc0d882cf623b7a1b6f6f305ec
When enabling DEBUG_POLL_AND_WAKE or DEBUG_CALLBACKS, compiler complains
for the undefined PRI* fprintf format constants.
Fix by including the missing cinttypes.
Test: m
Bug: none
Change-Id: I0a7b5b45bd274eefa9644cba491a8dc28f1992ff
libbacktrace only includes its Backtrace.cpp on the linux targets
but not windows or darwin targets. So, both should be disabled.
Previously, libutilscallstack was only ever a static library on
these platforms. Since nothing provided the symbols, these targets
couldn't have been used.
Fixes: 129636352
Test: m
Change-Id: I3f0b09e1d67c485b3ea57f58d1220d9516b326f2
The question arose on the bug of whether this is a legit errno or just
a stale value.
Bug: http://b/129139241
Test: ran tests
Change-Id: I486176496028f04d4fcccdd0b29a3df6b13849c9
The annotations for Mutex::tryLock and timedLock were
incorrectly specifying the return value for the successful
acquisition.
Test: make libutils_test
Change-Id: I9729b6555ede5cb1d6db046e33c35bf5926c7755
Having shared host libraries allows libraries depending on these to use
'shared_libs' for these. This simplifies configurations since these
libraries don't have to specify 'shared_libs' on all non-host targets.
Bug: 124524556
Test: build only
Change-Id: I09fb4a4fb66ea0a87cb76b1e6f400c537a11f082
Fix wp and sp comparison bugs
Make clear() actually clear wp m_refs, so that nulls compare equal.
Make equality consistent with < and >, ensuring that a weak pointer
cannot be both equal to and greater than another.
Don't rely on the built-in < and > operators to correctly order
different objects. The standard does not guarantee that, and there is
a risk of compiler relying on that lack of guarantee.
Remove unnecessary comparison overloads, especially those
comparing a wp<> to an sp<>.
Change the remaining wp<> to sp<> comparisons to check for equivalence
of the mRefs pointer instead of the object address, thus eliminating
the dubious equal comparison result for a dead wp<> and an sp<> that
happen to point to the same object address.
Add comparison tests.
This reverts commit a2a2ad8057.
The original code, and my original CL, both failed to initialize m_refs
in various wp<> constructors. This now became more important, since
comparisons now rely more on m_refs. However I believe it was always
a bug, since some comparisons always relied on m_refs.
Test: Treehugger, boot AOSP, atest RefBase
Bug: 126922090
This reverts commit a2a2ad8057.
Reason for revert: Reapply after constructor fixes.
Change-Id: I2c8917416a2306e36d2b6bb7b397f653020e5688
This reverts commit 029b12ebde.
Reason for revert: There appear to be problems with null comparisons. Reported failure in HwcBufferCacheTest.
Change-Id: I19745bb281dabe8b05c2df3fe95e7be7a49dcd51
Make clear() actually clear wp m_refs, so that nulls compare equal.
Make equality consistent with < and >, ensuring that a weak pointer
cannot be both equal to and greater than another.
Don't rely on the built-in < and > operators to correctly order
different objects. The standard does not guarantee that, and there is
a risk of compiler relying on that lack of guarantee.
Remove unnecessary comparison overloads, especially those
comparing a wp<> to an sp<>.
Change the remaining wp<> to sp<> comparisons to check for equivalence
of the mRefs pointer instead of the object address, thus eliminating
the dubious equal comparison result for a dead wp<> and an sp<> that
happen to point to the same object address.
Add comparison tests.
Test: Treehugger, boot AOSP, atest RefBase
Bug: 126922090
Change-Id: I15911150e0fc85ace2c4b77d337826e12793c690
Also move the singleton test out because our infrastructure can't cope
with tests that have their own test libraries.
Bug: http://b/124838889
Test: atest
Change-Id: Iddce3325a56d44a4288ace2a29921a3e02367413
Move tests in the same directory as the corresponding code, so it's
easier to see what is/isn't tested.
Fix naming of libcutils_tests (plural) to match the singular that's more
common (even though the plural makes more sense to me).
Add these two to system/core/'s TEST_MAPPING.
Remove obsolete AndroidTest.xml.
Fix a flaky (timing-dependent) libcutils test.
Test: ran tests
Change-Id: I7e0a31ff45c8a152562bf66fc97161594249366e
* changes:
DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
DO NOT MERGE: Revert "Revert "libcutils: Move sched_policy functions into libprocessgroup""
DO NOT MERGE: Revert "Revert "Add libprocessgroup into VNDK""
This reverts commit 1bef8c550c.
Reason for revert: AOSP is fixed with new vendor image
Change-Id: Ib341ac80e2f88c13a7815a490ea2d9422ebdf55f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
If this was strlcpy16 it wouldn't be such a bad idea, but strncpy16 is
just an accident waiting to happen...
Test: N/A
Change-Id: Id296fdeadfb9f1f70ddc8fb6d31b3b6b5178a12c
The lint rule google-default-arguments ensures that virtual or override
methods do not have default arguments, because different default values
across the hierarchy chain (e.g. Base::foo(int a=0) v.s.
Derived::foo(int a=10)) can cause confusions.
However, since the uses of the default arguments in libbinder don't lead
to such problem, suppress the warnings.
Test: WITH_TIDY=true WITH_TIDY_CHECKS=google-default-arguments m
libbinder does not show any warning about google-default-arguments
Change-Id: Ica41034ab0ad1037a0facc447ee47e0c77fa9c55
Add FALLTHROUGH_INTENDED for clang compiler.
Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
sp<>::clear() presents the same risks of heap corruption in the presence
of data races as does assignment. Add the same data race check.
Bug: 112651574
Test: Build and boot AOSP
Change-Id: I75d4eedd756d521920e61ff9187509f9145d4235
This reverts commit b9d0753d2b.
Reason for revert: Re-land with MacOS workaround.
Test: Build (on Linux) and boot AOSP, with weak symbols enabled and disabled.
Change-Id: I5150cd90367178f3b039761dca3bccc9c2987df1
This reverts commit 9d3146af22.
Reason for revert: It appears that weak symbols don't work as expected on MacOS, breaking the MacOS aapt build.
Change-Id: Ica0955106485a7bf2e2c3f09ff7910e230eb4139
Move towards crashing if a normally configured RefBase object is
destroyed without ever incrementing the reference count. We've been
threatening to do this for a long time. The previously last known
violation had been fixed.
This also fixes stack trace printing from RefBase, which had previously
been broken, and which we found necessary to track down further
violations of this rule.
Unfortunately, we found several more violations with the aid of
that fix. After existing CLs are submitted, there are
still some failures, but they are no longer numerous. Thus this CL
doesn't actually crash in the event of a violation, but does log a
verbose stack trace if it encounters one.
Bugs have been filed against the remaining known RefBase client offenders.
We plan to enable crashing on usage violations once those are fixed.
The fix for the stack trace printing breakage unfortunately requires
the use of weak symbols in order to avoid a circular build dependency.
We expect to eventually replace this with execinfo.h functionality.
Some random reformatting, driven by consistency with current formatting
requirements.
Add missing include to BacktraceMap.h.
Bug: 79112958
Bug: 30292291
Test: Boot AOSP, Master
Change-Id: I8151c54560c3b6f75ffc4c48229f0388a2066958
Switch Looper to using unique_fd for its owned file descriptors, to
benefit from fdsan.
Bug: http://b/111560345
Test: treehugger
Change-Id: I8efff7741ed19fd71f82f7e604b4f1c66fc5ea2b
adbd has been built as a static executable since the same binary was
copied to the recovery partition where shared library is not supported.
However, since we now support shared library in the recovery partition,
adbd is built as a dynamic executable.
In addition, the dependency from adbd to libdebuggerd_handler is removed
as debuggerd is handled by the dynamic linker.
A few more modules in /system/core are marked as recovery_available:
true as they are transitive dependencies of the dynamic linker.
This change also includes ld.config.recovery.txt which is the linker
config file for the recovery mode. It is installed to /etc/ld.config.txt
and contains linker namespace config for the dynamic binaries under
/sbin.
Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: Select 'mount /system' in the recovery mode, then `adb shell`.
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.
Change-Id: I363d5a787863f1677ee40afb5d5841321ddaae77
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.
Bug: 67916654
Bug: 64960723
Test: m -j
Change-Id: Ie59155c08890e96ce1893fa3687afcf763d7aea3