Commit Graph

441 Commits

Author SHA1 Message Date
Shuo Gao
0a885309aa fix corruption in Vector<> when malloc falied
1. When alloc or realloc failed in the function SharedBuffer::editResize,
it would return a NULL pointer, then mStorage would update to be 1 by
SharedBuffer::data() if no pointer check here, which is an obviously
wrong address, and would cause corruption when used it e.g. in capacity().

So add the pointer check here for the return value of SharedBuffer::editResize,
if it's NULL do not use it to update mStorage, to avoid the value of mStorage
polluted.

2. when alloc or realloc falied in _grow & _shrink function, mStorage keep
the original value, so mCount should not be updated here.

Otherwise, mStorage might be 0 but mCount>0, so a corruption would happend
when it try to delete items from the Vector since mCount>0.

Change-Id: I7c3814e843c459834ca5eed392e8d63d1cb7d2d8
Signed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Jian Luo <jian.luo@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 139626
2013-10-22 22:36:46 -07:00
Mathias Agopian
cab25d680e improved CallStack a bit
- added a ctor that updates and dumps the stack immediately
- added a "logtag" parameter to dump()

Change-Id: Ie51c256071d282591752243bdb4f68cf9ff8829d
2013-03-21 17:12:40 -07:00
Mathias Agopian
9cd766a517 disable RefBase consistency checks (NDEBUG)
Bug: 8328715
Change-Id: Ib57646ff909fd8744610f37f3b50d90d884dff31
2013-03-19 17:36:57 -07:00
Mathias Agopian
4e37ddff43 Fix a crasher with RefBase debugging and vectors of wp<>
background:
we have some code to fix-up the IDs of references when
using RefBase's DEBUG_REFS when those refs are managed by
arrays wp<> or sp<> (this is because wp<> / sp<> don't have
a trivial ctor when DEBUG_REFS is enabled, and Vector
treats them as trivial for obvious performance reasons)

this is complicated by the fact that we don't want to have
to recompile everything when enabling DEBUG_REFs (i.e.: the
Vector code cannot know wheter it's enabled or not for its
template stuff).

problem:
there was a bug in the fix-up code for wp<> which was trying
to access the weakref_impl from the RefBase* however, this was
moronic since RefBase could have been destroyed if there wasn't
any more strong refs -- and this happned. Instead we need to get
the weakref_impl directly from the wp<>

Change-Id: Ie16e334204205fdbff142acb9faff8479a78450b
2013-03-19 16:41:56 -07:00
Mathias Agopian
19437cb84c A few tweaks to RefBase debugging
- stacks are now saved in /data/debug which must be
  created and writable by the user.

- removed "always fatal" DEBUG_REFS option, it wasn't
  really needed.

- DEBUG_REFS_ENABLED_BY_DEFAULT is not the default anymore
  (usually people want to target which refs they're tracking)

Change-Id: I37fae72e9dacde6ce1fa8f7dbe2bc01b1a1b95e5
2013-03-18 22:59:40 -07:00
Jesse Hall
e81421e1cb Add Vector::resize()
Bug: 8384764
Change-Id: Icee83d389f3e555eba7d419b64c8d52a9aa21b8b
2013-03-15 12:40:39 -07:00
Dianne Hackborn
1791eefd69 fix a couple race-conditions in RefBase::promote()
Bug: 8390295
Change-Id: I7a48e3bf5b213cc1da2b8e844c6bb37ee24cb047
2013-03-14 16:47:41 -07:00
Mathias Agopian
f795852b54 temporary: enable ASSERTs in RefBase
this is in an attempt to get more data on
bug 8328715.

Change-Id: I9333a67c2d7f67f4d9b2fc5eb1ad8a7b2d1c6dcb
2013-03-11 21:27:16 -07:00
Romain Guy
dbca4a0ee5 Merge "Add Thread::isRunning and Condition::signal(WakeUpType)" into jb-mr2-dev 2013-03-11 21:38:26 +00:00
Romain Guy
9447be65c3 Add Thread::isRunning and Condition::signal(WakeUpType)
The signal() method is useful to choose whether to wake up one or
all threads.

Change-Id: I062ab6d3ddd306a9fb735549ea140e2a76eed75a
2013-03-11 14:34:56 -07:00
Mathias Agopian
e3e43b384e rename binder services main thread to Binder_*
When a binder service's main thread joins the thread pool
it retains its name (whatever the exec name was), which is
very confusing in systrace.

we now rename that thread just like its friends in the
thread pool.

Change-Id: Ibb3b6ff07304b247cfc6fb1694e72350c579513e
2013-03-07 15:34:28 -08:00
Mathias Agopian
dbf146f1d6 Fix RefBase debugging. O_CREAT must specify the mode.
Change-Id: I51c6df3cfd59b20ca73c3edee86bc2f74dbde1b1
2013-03-06 17:52:34 -08:00
Nick Kralevich
c4fd05b172 Revert "try to fix win_sdk build."
A better change was checked into system/core. See commit
941daef629bd571032851edf7ae1dce24266640e

This reverts commit fa99d30ec7.
2013-02-02 18:09:15 -08:00
Nick Kralevich
fa99d30ec7 try to fix win_sdk build.
Change-Id: I55e78e339874a6d6a3381c2550556b65c7ec1ca0
2013-02-01 16:09:23 -08:00
Marco Nelissen
32130635f6 Add NULL check to CallStack::toString
CallStack::toString() has a 0 default argument, which ends up getting
passed to strlen(), resulting in a crash.

Change-Id: If706aff8c400983670f49cdbb66e11191ac76e0e
2012-12-17 10:28:20 -08:00
Chris Craik
0a73f822b1 Add LinearAllocator
Moving from external/webkit/Source/WebCore/platform/graphics/android/utils/

Change-Id: If91830aa9b207dbc8692b2ca7c4a0b76778addd5
2012-12-05 17:34:54 -08:00
Alex Ray
653078f652 utils: clarify scoped tracing functionality
ScopedTrace objects were being used in place of ATRACE_NAME because of a
misunderstanding of it's function.  Cleared up documentation for usage.

Also explicitly use global namespace for sysprop callback.

Change-Id: I7c248b486b614ccdb841659ca0dcfc644fda670a
2012-11-30 19:54:00 -08:00
Alex Ray
b7e06477f0 utils: Use cutils tracing functionality.
Tracing functionality has moved to cutils.

Change-Id: Ie78ccc1d59dd5178f5058fbc3858a37f9adce552
2012-11-29 13:33:14 -08:00
Andy McFadden
2bdd8fd65a am 41f7736a: am 434e21bf: am 3fdeb48e: Reduce emulator logspam
* commit '41f7736ad1e72df8796416a82ce3cede6193d1eb':
  Reduce emulator logspam
2012-11-09 22:49:18 -08:00
Andy McFadden
41f7736ad1 am 434e21bf: am 3fdeb48e: Reduce emulator logspam
* commit '434e21bfd6b14f8d99b9bcdb829e7252edd574f3':
  Reduce emulator logspam
2012-11-09 22:45:13 -08:00
Andy McFadden
3fdeb48e3c Reduce emulator logspam
The emulator doesn't support systrace, but we should point that out
at most once per process.

Bug 7436352

Change-Id: I06b2c1ea0df6c02c11cd2496423c337f8d7c62a1
2012-11-08 16:40:11 -08:00
Raph Levien
3bc7b27571 Merge "Add an LRU cache plus hashing primitives" 2012-10-29 08:59:54 -07:00
Raph Levien
8185e47822 Add an LRU cache plus hashing primitives
This patch adds a hashtable-based LRU cache. This should be
significantly higher performance than the GenerationCache it is intended
to replace. It is a large part of the fix for bug 7271109
TextLayoutCache low-level performance issues.

We added a new method to BasicHashtable to detect when rehashing is
needed, because the internal linked list pointers would get invalidated
by that rehashing.

Also, the hash_type specialized to pointers had a small flaw.

Change-Id: I950c2083f96519777b851dbe157100e0a334caec
2012-10-26 16:09:22 -07:00
Dave Burke
296cd1cb9a am 04075569: Revert "Revert "put back the unused virtuals in Vector<>""
* commit '04075569b565c949a6db8b4e8a9f10d281de4d9c':
  Revert "Revert "put back the unused virtuals in Vector<>""
2012-10-25 11:45:41 -07:00
Dave Burke
04075569b5 Revert "Revert "put back the unused virtuals in Vector<>""
This reverts commit 225c66a48c

Change-Id: If31a04b81052cbc7dd7bf237c07107c33066d03d
2012-10-25 11:40:51 -07:00
Kenny Root
3fe50abbfd am 125becee: am 7abbbc68: Merge "Add TEMP_FAILURE_RETRY to ZipUtils"
* commit '125beceefd44f6abd17ff336bb989e1850965bd8':
  Add TEMP_FAILURE_RETRY to ZipUtils
2012-10-16 16:29:17 -07:00
Kenny Root
d611117f24 Add TEMP_FAILURE_RETRY to ZipUtils
Change-Id: I275c415f14eeffaf9a58d45f3ea014d766441ec3
2012-10-16 14:00:56 -07:00
Kenny Root
e2e95c8ccb am 9bdaa60b: Merge "Add TEMP_FAILURE_RETRY around open and write calls" into jb-mr1-dev
* commit '9bdaa60b809b223d14619d1f13afdd38acb1738d':
  Add TEMP_FAILURE_RETRY around open and write calls
2012-10-12 23:43:29 -07:00
Kenny Root
3de9cd2029 Add TEMP_FAILURE_RETRY around open and write calls
Bug: 7330849
Change-Id: I9aef3c3d3a248c3eea7ca060124ad6decaa6b4da
2012-10-12 11:37:58 -07:00
Kenny Root
7011d5a46b am ee42072b: am 52f1edb3: Merge "Update tests for new build target"
* commit 'ee42072bcccab880dd685736a32a56ac62ffc331':
  Update tests for new build target
2012-10-02 09:55:49 -07:00
Kenny Root
ed22c1cfe5 Update tests for new build target
Change-Id: Ia1740d1b2c0b611c4559c5c846b12fb5c3e81b07
2012-10-02 09:42:49 -07:00
Ben Cheng
971f7e9f5d Disable the use of clock_gettime for now.
Bug: 7100774
Change-Id: I6ede2a37a5d485134fe419b5dc766f70ae4af9d4
2012-09-19 14:53:10 -07:00
Ben Cheng
8dc7c6e659 Print warnings when backwards timestamps are detected.
Bug: 7100774

Change-Id: I752fd1680b32ce33d17d6042d6c82e27d7ba9dd2
2012-09-16 16:21:01 -07:00
Mathias Agopian
50f262fe56 minor SharedBuffer clean-up
Change-Id: If38b7ce85806ae628c00f2c938de4e3f75142543
2012-08-31 18:41:21 -07:00
Mathias Agopian
225c66a48c Revert "put back the unused virtuals in Vector<>"
This reverts commit 1648d4c13b.

Bug: 6977192

Change-Id: Idbb6b239aaed4fb1c054ce943f6ba06ede3492bb
2012-08-24 17:16:10 -07:00
Mathias Agopian
1648d4c13b put back the unused virtuals in Vector<>
some binaries are using these private APIs and broke
(as they should!) with this change. Temporarily restore the
virtuals to work around this.

Bug: 6977550
Change-Id: I7c37f24b16e4d586b89205c493db5169cf87e024
2012-08-20 21:23:15 -07:00
Jeff Brown
6f12d57325 Add a very simple helper function to log slow functions.
Change-Id: I2e2e072206d02b572a330dd25857c161b5b563bf
2012-08-10 22:03:55 -07:00
Mathias Agopian
69973992d5 improve Vector<> safety checks
- make errors that will always cause a memory corruption always fatal
  (for eg: KeyedVector<>::editValue{For|At}() failure)
- make other errors fatal in debug mode, those that can be caught by
  the caller.
- fix typos

Change-Id: I65cc7d81035c37ce2906fc4500c50e5d5b5c49eb
2012-08-10 13:15:00 -07:00
Mathias Agopian
53095e25d6 libutils cleanup: remove unused or seldom used code from misc.{cpp|h}
Change-Id: I72206f16619d81887e3b85603494563faab3b445
2012-08-05 12:41:16 -07:00
Nick Pelly
074cd0c076 Add elapsedRealtimeNano(), and use CLOCK_BOOTTIME where possible.
Change-Id: I4231c8ca32663e6e2cb5b7c126d091f837373807
2012-07-19 16:06:21 -07:00
John Grossman
ec44ed0758 Utils: Fix a bug in the linear transformation code.
Hand merge from ics-aah

> Utils: Fix a bug in the linear transformation code.
>
> Fix a bug where an incorrect result would be computed if you used the
> linear transformation code to do a reverse transformation (from B's
> domain into A's domain) when the scaler fraction was negative.
>
> Change-Id: I8e5f109314d235a177ab41f65d3c4cd08cff78be
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: Id90e18f685c61c1a89fd91c32adcf01363b3e8f3
Signed-off-by: John Grossman <johngro@google.com>
2012-06-27 15:34:43 -07:00
Jeff Brown
9a6b4c73fa am d5085da3: am 4467bba7: Merge "Support looper callbacks based on smart pointers." into jb-dev
* commit 'd5085da3c0c103bba0c2c927382f7d414275b661':
  Support looper callbacks based on smart pointers.
2012-05-31 18:43:27 -07:00
Jeff Brown
ad7b3760ce am 80586761: am dad23789: Merge "Delete unused poll() code." into jb-dev
* commit '805867612c0c11d3bb494cbf454cbb2de21a1b75':
  Delete unused poll() code.
2012-05-31 18:43:26 -07:00
Jeff Brown
27d928474d am dce1547d: am 9e2e781a: Merge "Remove unused statistics code." into jb-dev
* commit 'dce1547d65877b89cec4e52ee8e5b39830911d00':
  Remove unused statistics code.
2012-05-31 18:43:26 -07:00
Jeff Brown
af567f73ac Support looper callbacks based on smart pointers.
Bug: 6559630
Change-Id: I5a667f219f431838638acefbc9fa6afa610971bd
2012-05-31 17:16:21 -07:00
Jeff Brown
588d5c8280 Delete unused poll() code.
We don't need this code anymore and it is just in the way.

Bug: 6559630
Change-Id: I1dc9decf85d5ea1feab159c2985da6c20baffdd5
2012-05-30 19:21:12 -07:00
Jeff Brown
1ea51bf519 Remove unused statistics code.
Bug: 6559630
Change-Id: Iacdf4bb4c1c125c09305cbd8cb443c7c80cfc010
2012-05-30 19:17:47 -07:00
Mathias Agopian
455961ef65 am e0607f05: am 5aed6843: Merge "fix a corruption in Vector<> when adding new items" into jb-dev
* commit 'e0607f0507fe647bd9262facfaf75146c074e933':
  fix a corruption in Vector<> when adding new items
2012-05-21 12:43:25 -07:00
Mathias Agopian
a9611c5d5b fix a corruption in Vector<> when adding new items
would happen when vectors are copied and new items is
added in both vectors. we didn't duplicate the underlying
storage when adding items in vectors.

Bug: 6515797
Change-Id: If544c07d96c05821e088d7f2c9b5736f7e306c31
2012-05-17 17:47:44 -07:00
Glenn Kasten
9121ece5fc am f30fd014: Merge "Workaround for add_tid_to_cgroup failed to write" into jb-dev
* commit 'f30fd01497a53cbff8692721026c3f7b6830158e':
  Workaround for add_tid_to_cgroup failed to write
2012-05-10 17:45:21 -07:00