Commit graph

70 commits

Author SHA1 Message Date
Mark Salyzyn
66ce3e08c5 system/core Replace cutils/log.h with android/log.h
Should use android/log.h instead of cutils/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I2c9cbbbd64d8dccf2d44356361d9742e4a9b9031
2016-09-30 12:47:05 -07:00
Sergio Giro
1cfa56d46c libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8
Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length
is causing a heap overflow.

Correcting the length computation and adding bound checks to the
conversion functions.

Test: ran libutils_tests
Bug: 29250543
Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb
(cherry picked from commit c4966a363e)
2016-08-25 20:07:51 +00:00
Sergio Giro
9de6776321 Unicode: specify destination length in utf8_to_utf16 methods
String16(const char *utf8) now returns the empty string in case
a string ends halfway throw a utf8 character.

Bug: 29267949
Clean cherry-pick from 1dcc0c8239

Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
2016-08-25 19:57:06 +00:00
Hans Boehm
daac359be7 Merge "Make RefBase more robust and debuggable" 2016-08-24 23:36:13 +00:00
Hans Boehm
23c857ebd6 Make RefBase more robust and debuggable
This prevents two different kinds of client errors from causing
undetected memory corruption, and helps with the detection of others:

1. We no longer deallocate objects when the weak count goes to zero
and there have been no strong references.  This otherwise causes
us to return a garbage object from a constructor if the constructor
allocates and deallocates a weak pointer to this. And we do know
that clients allocate such weak pointers in constructors and their
lifetime is hard to trace.

2. We abort if a RefBase object is explicitly destroyed while
the weak count is nonzero.  Otherwise a subsequent decrement
would cause a write to potentially reallocated memory.

3. We check counter values returned by atomic decrements for
plausibility, and fail immediately if they are not plausible.

We unconditionally log any cases in which 1 changes behavior
from before. We abort in cases in which 2 changes behavior, since
those reflect clear bugs.
In case 1, a log message now indicates a possible leak. We have
not seen such a message in practice.

The third point introduces a small amount of overhead into the
reference count decrement path. But this should be negligible
compared to the actual decrement cost.

Add a test for promote/attemptIncStrong that tries to check for
both (1) above and concurrent operation of attemptIncStrong.

Add some additional warnings and explanations to the RefBase
documentation.

Bug: 30503444
Bug: 30292291
Bug: 30292538

Change-Id: Ida92b9a2e247f543a948a75d221fbc0038dea66c
2016-08-13 11:17:51 -07:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Sergio Giro
4476929073 Merge \"LruCache: avoid copying keys in lookup\"
am: 896c6b14ae

Change-Id: If8223e90988510385378506cd3a05d382ab73fc9
2016-07-20 19:48:44 +00:00
Sergio Giro
4c56e0a222 LruCache: avoid copying keys in lookup
Create objects of type KeyedEntry for lookups that only have
a key reference

Bug: 27567036
Change-Id: I5e609a3db63d3b9277ff1547a3cca37dce70251c
2016-07-20 18:38:44 +00:00
Hans Boehm
2b67ca305e Merge \"Add test for RefBase etc.\"
am: dc9fbc3440

Change-Id: I77ead7f91c17ee8c5614da783152ac3478fc5342
2016-07-14 00:44:58 +00:00
Hans Boehm
4a8276c779 Add test for RefBase etc.
Add some basic tests for RefBase, as well as a more ambitious memory
ordering test.

Add a README.txt with instructions to run the tests.

Comment out a couple of BlobCache tests that failed consistently and
appeared to be incorrect.  With that fix, I managed to run
libutils_tests successfully on device.

Bug: 28705989
Change-Id: I8ad29995097a149a0cc38615d6ed37117ec6cb5c
2016-07-13 12:03:03 -07:00
Colin Cross
2fedbf79bb resolve merge conflicts of 41e82a3 to stage-aosp-master
Change-Id: I5a7faca3249f0c038914540b1dd29edf0084c0e1
2016-07-12 23:53:04 -07:00
Dan Willemsen
2e1591bef9 Convert libbacktrace, libutils to Soong
Change-Id: I8b578f671f92246aca61f98937d75a60b56bc5c6
2016-07-12 17:20:18 -07:00
Greg Hackmann
8f9a6372f6 Merge "SystemClock: add test" am: 282e8fb037
am: a91a1a990f

* commit 'a91a1a990f1d629377dcd2c3f2b57ccab48dc8cf':
  SystemClock: add test

Change-Id: I547a4c3422eb468530e3cdd02eb2bb157a444a15
2016-05-16 18:23:41 +00:00
Michael Wright
2a9a993af9 Merge commit '8b452b876b90dcfff1dab9012b65b5e67c4531a4' into manual_merge_8b452b8
Change-Id: Iacdc2d521f669661b4979c03b0476512abdb37c7
2016-05-16 15:06:22 +01:00
Michael Wright
5bacef33c9 Add String16#contains and strstr16 methods.
These are needed for aapt to find javadoc comments that contain
"@removed" in order to skip them when printing styleable docs.

Bug: 28663748
Change-Id: I8866d2167c41e11d6c2586da369560d5815fd13e
2016-05-09 19:45:07 +01:00
Greg Hackmann
340079df26 SystemClock: add test
Bug: 28357356

Change-Id: Idf66c048bda09cd8cb08adf89ed0edd3770c4e39
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-05-02 13:59:58 -07:00
Brian Carlstrom
de6d6041c1 system/core: Make Thread::run threadName argument required
am: e71b914775

* commit 'e71b9147756ab4da306e4c16461ad23936769603':
  system/core: Make Thread::run threadName argument required
2016-03-14 15:24:54 +00:00
Brian Carlstrom
e71b914775 system/core: Make Thread::run threadName argument required
Bug: 27557176
Change-Id: Iae83a1e5489c86c2858fc8481f246b8480f0eec4
2016-03-12 21:32:52 -08:00
James Hawkins
650ba8b8d6 Merge "system/core/lib[c]utils: Fix signedness comparison warnings." am: bba2151b29
am: 65df16b05f

* commit '65df16b05f8d590e1fccc19e9a28833d6a71567d':
  system/core/lib[c]utils: Fix signedness comparison warnings.
2016-03-01 20:32:09 +00:00
James Hawkins
b898075f30 system/core/lib[c]utils: Fix signedness comparison warnings.
* Store the output of a length variable in size_t.
* Annotate unsigned constant values as such.

Bug: 27384813
Change-Id: I8504c0a8f5840d4d42e5c0df797a4e5d02d13eb9
2016-03-01 11:21:53 -08:00
Sergio Giro
43f13d0d68 Merge "libutils: fix cache removal when callback invalidates the key" am: b0df9dca7c am: e483305e47
am: a96cd36afb

* commit 'a96cd36afbff682e24365092dd85bbe9c9165afc':
  libutils: fix cache removal when callback invalidates the key
2015-11-20 17:17:38 +00:00
Sergio Giro
b7170fe3fe libutils: fix cache removal when callback invalidates the key
Bug: 24785286
Change-Id: I9d17d2247258a56ef7776b3a701389e825a9c533
2015-11-20 14:54:51 +00:00
John Reck
dc7694eac5 Merge "Teach sp<> how to std::move" am: 518d043c86 am: bb12b91ae1
am: a573d6b186

* commit 'a573d6b18686266667c8efd9d7291ecd28efa67c':
  Teach sp<> how to std::move
2015-11-03 00:14:15 +00:00
John Reck
bb12b91ae1 Merge "Teach sp<> how to std::move"
am: 518d043c86

* commit '518d043c8693835061b02ecbbee4b82fc61a776e':
  Teach sp<> how to std::move
2015-11-02 21:39:24 +00:00
John Reck
d69089a742 Teach sp<> how to std::move
Arguably we should migrate to std::shared_ptr
but for now make std::vector<sp<>> a bit less
horrible

Change-Id: Ia458a2daff0b656b2f3310b3ea100565ec844c69
2015-10-29 07:17:40 -07:00
Sergio Giro
d155004e78 am 51209a8b: am 9443fd94: am f8376607: Merge "system/core: fix iterator for LruCache"
* commit '51209a8b93d85f8b7f3b6a106c41c1aa03190f2c':
  system/core: fix iterator for LruCache
2015-10-13 07:45:36 +00:00
Sergio Giro
9443fd94e3 am f8376607: Merge "system/core: fix iterator for LruCache"
* commit 'f83766079e248e04065103a4720364c0193777ee':
  system/core: fix iterator for LruCache
2015-10-13 07:36:52 +00:00
Sergio Giro
0cb59c0dce system/core: fix iterator for LruCache
Was failing to return the first element

Change-Id: Ic803f5d463a56519212014d0d190407cf4b859cf
2015-10-12 16:13:44 +01:00
Sergio Giro
a5f71e075a system/core: remove BasicHashtable
Towards deprecation of SharedBuffer

Change-Id: Id6d1c8637583df38b6f28398b6804d9c1e96472a
(cherry picked from commit f84a4906fa)
2015-10-01 13:18:13 -07:00
Sergio Giro
075f690dae am bdae9bf2: resolved conflicts for 70808827 to stage-aosp-master
* commit 'bdae9bf2ec3bbf8e33a34caa412bd8fd7bc2d434':
  system/core: remove BasicHashtable
2015-10-01 18:59:59 +00:00
Sergio Giro
45dd164bff Revert "resolved conflicts for 70808827 to stage-aosp-master"
This reverts commit 5cf2d5c9cc.

Change-Id: Ifcffff034d4610c0d318cf67b0d98a28551c9605
2015-10-01 18:33:25 +00:00
Sergio Giro
5cf2d5c9cc resolved conflicts for 70808827 to stage-aosp-master
Change-Id: I5e5030a20f2be3bd15b9fec8192dd22ec5a34d87
2015-10-01 18:54:33 +01:00
Sergio Giro
f84a4906fa system/core: remove BasicHashtable
Towards deprecation of SharedBuffer

Change-Id: Id6d1c8637583df38b6f28398b6804d9c1e96472a
2015-10-01 11:44:47 +01:00
Sergio Giro
9428978318 am fbb259e8: am 8e2c8208: am 730fdbb1: Merge "system/core: change LruCache to use unordered_set instead of BasicHashTable"
* commit 'fbb259e83633c35c5e6ede1d5f55f5672ab433d0':
  system/core: change LruCache to use unordered_set instead of BasicHashTable
2015-09-30 13:31:45 +00:00
Sergio Giro
fbb259e836 am 8e2c8208: am 730fdbb1: Merge "system/core: change LruCache to use unordered_set instead of BasicHashTable"
* commit '8e2c8208198c1c73c7192b1bd5e87868b53297c6':
  system/core: change LruCache to use unordered_set instead of BasicHashTable
2015-09-30 13:26:23 +00:00
Sergio Giro
bb58cde899 system/core: change LruCache to use unordered_set instead of BasicHashTable
Towards deprecation of BasicHashTable

Change-Id: I3f3d904636a85a794cccf972f6e4a94e7f3808f5
2015-09-30 13:48:30 +01:00
Brian Carlstrom
7ae1d6590b am 16bed965: am 742d0173: am 661600dd: am 110f705e: resolved conflicts for 832a0d1c to mnc-dev
* commit '16bed9650aa493194b4091700ac81c9c882d96b2':
  libutils: Fix integer overflows in VectorImpl.
2015-09-20 01:25:14 +00:00
Brian Carlstrom
16bed9650a am 742d0173: am 661600dd: am 110f705e: resolved conflicts for 832a0d1c to mnc-dev
* commit '742d0173e8bd41e137d175c04860c532270b3f5b':
  libutils: Fix integer overflows in VectorImpl.
2015-09-20 01:21:47 +00:00
Brian Carlstrom
110f705e10 resolved conflicts for 832a0d1c to mnc-dev
Change-Id: Ic46ee60de7bc500f4e1d5fe841524db80918a8d9
2015-09-19 17:29:42 -07:00
Brian Carlstrom
832a0d1c64 resolved conflicts for cf676a86 to lmp-mr1-ub-dev
Change-Id: Ifd9a44777a472ae893f894391bff7ef81456d92c
2015-09-19 16:13:00 -07:00
Narayan Kamath
419e6c3c68 libutils: Fix integer overflows in VectorImpl.
Use external/safe-iop to check for overflows on arithmetic
operations.

Also remove an unnecessary copy of Vector/SharedBuffer from
codeflinger and use the copy from libutils instead.

Note that some of the unit tests are somewhat useless due to
test-runner limitations : gtest's ability to filter on abort message
doesn't work when combined with messages formatted by android's logging
system.

bug: 22953624

(cherry picked from commit c609c31fb5)

Change-Id: I61644633db6b54fa230683615de9724f7fabf6fb
2015-09-09 12:05:06 +01:00
Narayan Kamath
69b9a8bf21 am 51e740f8: resolved conflicts for 32d86587 to mnc-dr-dev-plus-aosp
* commit '51e740f802083cc250a2f6228222bcbbcec79887':
  libutils: Fix integer overflows in VectorImpl.
2015-09-08 13:07:52 +00:00
Narayan Kamath
51e740f802 resolved conflicts for 32d86587 to mnc-dr-dev-plus-aosp
Change-Id: I381133e7dd93f908bd3d2b42e8af83d954e428af
2015-09-08 13:59:49 +01:00
Sergio Giro
df5151d30f libutils: add test for String8
Test crashes with SIGSEGV without the fix in b/23290056, passes otherwise.

Bug: 23290056
Change-Id: I6daca0aa07b5e97b004a9606a0227227fae11896
2015-09-07 17:12:45 +01:00
Narayan Kamath
c609c31fb5 libutils: Fix integer overflows in VectorImpl.
Use external/safe-iop to check for overflows on arithmetic
operations.

Also remove an unnecessary copy of Vector/SharedBuffer from
codeflinger and use the copy from libutils instead.

Note that some of the unit tests are somewhat useless due to
test-runner limitations : gtest's ability to filter on abort message
doesn't work when combined with messages formatted by android's logging
system.

bug: 22953624

Change-Id: I46b1ae8ca1f3a010be13aca36a091e76a97a7b70
2015-09-02 12:37:49 +01:00
Nick Kralevich
3e6c451908 libutils: fix signed/unsigned comparison warnings
Change-Id: Ib283c85a404a20688c5357fa513e5d07c2f42803
2015-08-17 20:54:15 -07:00
Elliott Hughes
bcc2b5f44a Remove LOCAL_ADDITIONAL_DEPENDENCIES in cases where it's not needed.
Change-Id: I720b8ef1050da45a7833adef8219b6acb2cf3a38
2015-04-02 14:31:07 -07:00
Dan Albert
c007bc3856 Revert "Revert "Create libbase.""
This reverts commit a7870d8816.
2015-03-16 10:08:46 -07:00
Nicolas Geoffray
a7870d8816 Revert "Create libbase."
Breaks internal master.

This reverts commit 98ff77204c.

Change-Id: I18dc6021cb43efff8aa88486c2d980dc2b8eedba
2015-03-16 11:07:29 +00:00