android_system_core/include/utils
Hans Boehm e263e6c633 Fix memory order and race bugs in Refbase.h & RefBase.cpp
Convert to use std::atomic directly.

Consistently use relaxed ordering for increments, release ordering
for decrements, and an added acquire fence when the count goes to
zero.

Fix what looks like another race in attemptIncStrong:
It seems entirely possible that the final adjustment for
INITIAL_STRONG_VALUE would see e.g. INITIAL_STRONG_VALUE + 1,
since we could be running in the middle of another initial
increment.

Attempt to somewhat document what this actually does, and
what's expected from the client. Hide the documentation in
the .cpp file for now.

Remove a confusing redundant test in decWeak. OBJECT_LIFETIME_STRONG
and OBJECT_LIFETIME_WEAK are the only options, in spite of some
of the original comments.

It's conceivable that either of these issues has resulted in
actual crashes, though I would guess the probability is small.
It's hard enough to reason about this code without the bugs.

Bug: 28705989
Change-Id: I4107a56c3fc0fdb7ee17fc8a8f0dd7fb128af9d8
2016-05-17 16:11:11 -07:00
..
AndroidThreads.h Use __ANDROID__ instead of HAVE_ANDROID_OS. 2015-07-30 09:33:43 -07:00
Atomic.h
BitSet.h
BlobCache.h Adding a build id check to blob cache. 2015-05-18 13:14:32 -07:00
ByteOrder.h Use _WIN32 rather than HAVE_WINSOCK. 2015-07-29 17:45:24 -07:00
CallStack.h
Compat.h utils: add pwrite64 to Compat.h for Mac 2015-09-28 16:52:38 +01:00
Condition.h Fix Condition::waitRelative. 2016-04-04 14:51:21 -07:00
Debug.h
Endian.h
Errors.h libutils: Add UNEXPECTED_NULL status_t 2015-11-10 11:12:43 -08:00
FileMap.h Implement C++11 move semantics for android::FileMap 2015-10-01 12:47:49 -07:00
Flattenable.h
Functor.h
JenkinsHash.h libutils: cleanups for -fsanitize=integer 2015-08-24 15:52:22 +00:00
KeyedVector.h
LinearTransform.h
List.h
Log.h
Looper.h
LruCache.h libutils: fix cache removal when callback invalidates the key 2015-11-20 14:54:51 +00:00
Mutex.h Use __ANDROID__ instead of HAVE_ANDROID_OS. 2015-07-30 09:33:43 -07:00
NativeHandle.h
Printer.h
ProcessCallStack.h
PropertyMap.h
RWLock.h
RefBase.h Fix memory order and race bugs in Refbase.h & RefBase.cpp 2016-05-17 16:11:11 -07:00
Singleton.h
SortedVector.h
StopWatch.h
String8.h libutils: add String8 and String16 std_string utility methods 2016-02-18 17:04:23 -08:00
String16.h libutils: add String8 and String16 std_string utility methods 2016-02-18 17:04:23 -08:00
StrongPointer.h Teach sp<> how to std::move 2015-10-29 07:17:40 -07:00
SystemClock.h
Thread.h Use __ANDROID__ instead of HAVE_ANDROID_OS. 2015-07-30 09:33:43 -07:00
ThreadDefs.h Fix windows 64-bit builds 2016-02-05 16:10:10 -08:00
Timers.h
Tokenizer.h
Trace.h Use __ANDROID__ instead of HAVE_ANDROID_OS. 2015-07-30 09:33:43 -07:00
TypeHelpers.h TypeHelpers.h: Don't underflow unsigned int 2015-06-13 17:49:24 -07:00
Unicode.h
Vector.h
VectorImpl.h
misc.h
threads.h