No description
Find a file
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
adb std::unqiue_ptr<..., decltype(&fn)> seems to be the preferred idiom. 2016-08-08 12:52:37 -07:00
adf Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
base Move init's kernel logging into libbase. 2016-08-04 16:09:39 -07:00
bootstat bootstat: Fix a potential unhandled exception for malformed input. 2016-07-28 11:59:22 -07:00
cpio fs_config: replace getenv('OUT') by new fs_config parameter 2015-07-09 21:47:07 -07:00
crash_reporter Remove Brillo-specific LOCAL_MODULE_TAGS 2016-07-31 18:45:14 -07:00
debuggerd Define TARGET_IS_64_BIT when building libdebuggerd_client for android64. 2016-08-09 14:04:05 -04:00
fastboot Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
fingerprintd Fix google-explicit-constructor warnings. 2016-04-29 15:44:04 -07:00
fs_mgr libcrypto_utils: convert to Soong. 2016-08-05 18:07:36 -07:00
gatekeeperd Fix google-explicit-constructor warnings. 2016-04-29 15:44:04 -07:00
healthd Fix clang-tidy performance warnings in healthd. 2016-07-27 16:05:50 -07:00
include Make RefBase more robust and debuggable 2016-08-13 11:17:51 -07:00
init Merge "libcrypto_utils: convert to Soong." 2016-08-08 18:29:10 +00:00
libbacktrace Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
libbinderwrapper core: Update libchrome APIs to r395517 2016-05-26 11:29:53 -07:00
libcrypto_utils libcrypto_utils: convert to Soong. 2016-08-05 18:07:36 -07:00
libcutils Merge "libcutils: add sched_policy test" 2016-08-04 16:24:30 +00:00
libdiskconfig Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
libion Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
liblog Fix google-explicit-constructor warnings in system/core. 2016-07-26 11:26:01 -07:00
libmemtrack Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
libmemunreachable Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
libnativebridge Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
libnativeloader libnativeloader: convert Android.mk to Android.bp 2016-07-27 10:36:36 -07:00
libnetutils libnetutils: Add synchronization per socket full operation 2016-06-07 10:11:59 -07:00
libpackagelistparser Convert libpackagelistparser to Android.bp 2016-07-19 22:19:37 -07:00
libpixelflinger Fix google-explicit-constructor warnings in system/core. 2016-07-26 11:26:01 -07:00
libprocessgroup Switch libprocessgroup to libbase logging. 2016-08-03 09:11:04 -07:00
libsparse Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
libsuspend Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
libsync libsync: add static library for recovery 2016-08-05 15:03:58 -07:00
libsysutils Clean up CLOEXEC in SocketListener. 2016-02-19 18:14:22 -08:00
libusbhost libusbhost: Fix problem reading USB string descriptors on some quirky devices 2015-06-18 13:38:31 -07:00
libutils Make RefBase more robust and debuggable 2016-08-13 11:17:51 -07:00
libziparchive Convert libziparchive from Android.mk to Android.bp 2016-07-12 21:01:08 -07:00
lmkd Fix misc-macro-parentheses warnings in lmkd. 2016-05-18 15:37:20 -07:00
logcat logcat: -d, -t or -L, along with -f, do not background 2016-08-08 10:20:22 -07:00
logd logd: klogd crash 2016-08-08 09:58:28 -07:00
logwrapper Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
metricsd Remove Brillo-specific LOCAL_MODULE_TAGS 2016-07-31 18:45:14 -07:00
mkbootimg mkbootimg: use int for os_version and os_patch_level 2016-03-29 16:06:37 -07:00
reboot Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
rootdir init: usb: delete rndis func to unregister n/w interface 2016-07-19 13:11:50 +05:30
run-as run-as: Use Minijail for privilege dropping. 2016-07-19 11:03:52 -04:00
sdcard Fix sdcard logging. 2016-07-26 16:52:48 -04:00
toolbox Lose sendevent to toybox. 2016-07-15 14:17:28 -07:00
trusty Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
tzdatacheck Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
.gitignore Ignore adb/*.pyc files 2015-08-11 12:59:58 -07:00
Android.mk Remove the simulator target from all makefiles. 2011-07-11 22:12:32 -07:00
CleanSpec.mk Use BOARD_USES_VENDORIMAGE to detect vendor image presence 2016-07-08 18:17:48 -07:00
MODULE_LICENSE_APACHE2 auto import from //depot/cupcake/@135843 2013-07-30 13:56:49 -07:00
NOTICE Fix omission in NOTICE file. 2013-07-30 13:56:55 -07:00