Commit graph

2366 commits

Author SHA1 Message Date
Elliott Hughes
091113ec6c Merge "Remove socket_loopback_client."
am: 5171bebf41

Change-Id: I28080f043ba5a042573e81a6da3f5be83c7a4251
2016-10-14 20:37:06 +00:00
Treehugger Robot
5171bebf41 Merge "Remove socket_loopback_client." 2016-10-14 18:21:38 +00:00
Mark Salyzyn
9ea359fce0 liblog: LIBLOG_ABI_PRIVATE __android_log_is_debuggable()
Allow our own libraries to use this privately instead of
running the less efficient get_properties and doing the math.

Test: compile and boot smoke test
Bug: 27566046
Bug: 31456426
Change-Id: I2f677276d27fbcb6af01b600ac1d9891c8938d43
2016-10-14 08:00:41 -07:00
Tao Wu
4b9774fe97 Merge "Fallback to IPv6 when IPv4 is not available in adb" am: c32d7fd66f am: 5b7c6772b0
am: 27c6c4cf04

Change-Id: I2ceb40b4589dfc2721197065ae5a85e9dc83b907
2016-10-14 01:51:54 +00:00
Tao Wu
27c6c4cf04 Merge "Fallback to IPv6 when IPv4 is not available in adb" am: c32d7fd66f
am: 5b7c6772b0

Change-Id: I63e945622d47ab1cbcbdd82d00cfdf3d51c95564
2016-10-14 01:46:26 +00:00
Treehugger Robot
c32d7fd66f Merge "Fallback to IPv6 when IPv4 is not available in adb" 2016-10-14 01:35:43 +00:00
Elliott Hughes
dd92a0a812 Remove socket_loopback_client.
Bug: http://b/31537253
Test: builds
Change-Id: If02c8107206fb60e4622f8937bee0d0a362e1c7d
2016-10-13 16:51:46 -07:00
Chia-I Wu
7e671b343f Merge "Add native_handle_init" am: d790aae4bc am: 28423b86fe
am: bf72cf21dc

Change-Id: I5d4cc013421350dd30fa13d168112d30ad93e7cd
2016-10-13 22:32:57 +00:00
Chia-I Wu
bf72cf21dc Merge "Add native_handle_init" am: d790aae4bc
am: 28423b86fe

Change-Id: Ied7a062c6ce40864ea181819f5da21e64cae04de
2016-10-13 22:26:11 +00:00
Tao Wu
7b700763f5 Fallback to IPv6 when IPv4 is not available in adb
Test: manual - make sure it works in both IPv4/IPv6 env.
BUG: 31537253
Change-Id: Ica492bff34a8c0441516a213d0e8b78fcdfd3282
Signed-off-by: Tao Wu <lepton@google.com>
2016-10-13 08:54:43 -07:00
Chia-I Wu
b843791b61 Add native_handle_init
HIDL requires file descriptors to be wrapped in native_handle_t.  We want
a low overhead way to do that when the number of file descriptors is known
at compile time.  Instead of

  // wrap an fd in native_handle_t
  native_handle_t* fd_handle = native_handle_create(1, 0);
  if (!fd_handle) {
    // clean up and return error
  }
  fd_handle->data[0] = fd;

  hidl_cb(..., fd_handle);

  native_handle_delete(fd_handle);

this change adds native_handle_init to allow for

  // wrap an fd in native_handle_t
  NATIVE_HANDLE_DECLARE_STORAGE(fd_storage, 1, 0);
  native_handle_t* fd_handle = native_handle_init(fd_storage, 1, 0);
  fd_handle->data[0] = fd;

  hidl_cb(..., fd_handle);

Test: make libcutils
Bug: 32021609
Change-Id: If1fd07482243d37492fdea57c602a1b13c8953cc
2016-10-12 18:04:41 -07:00
Mark Salyzyn
144abd8cb2 Merge "liblog: adb: move security interfaces to private" am: 09dac589f1 am: 586c6985cf
am: 4b5456eacc

Change-Id: Id78628d7e7abfa16f1ada16f894f9616a2dc469b
2016-10-10 23:34:54 +00:00
Mark Salyzyn
4b5456eacc Merge "liblog: adb: move security interfaces to private" am: 09dac589f1
am: 586c6985cf

Change-Id: I8c54bdc1a3582be1fc7c4a9be83b555624fcb0a3
2016-10-10 23:29:55 +00:00
Mark Salyzyn
6debf985aa liblog: adb: move security interfaces to private
Test: Compile & adb functioning
Bug: 19235719
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: I7ad8963bcca3d8b5c37b547c11d163b652d35556
2016-10-10 15:15:45 +00:00
Chia-I Wu
ebebf0198d Merge "Add native_handle_clone" am: e8f6c7398b am: 462e087e40
am: cb52dc258e

Change-Id: I011555d429120a26e61fbce5f7a125ce96fadb3f
2016-10-08 01:39:01 +00:00
Chia-I Wu
cb52dc258e Merge "Add native_handle_clone" am: e8f6c7398b
am: 462e087e40

Change-Id: I745341bf4c76fc8c75f36e578cf1086808119426
2016-10-08 01:34:05 +00:00
Chia-I Wu
e8f6c7398b Merge "Add native_handle_clone" 2016-10-08 01:25:35 +00:00
Elliott Hughes
c9dc124e2f Merge "Test for _WIN32 in instead of USE_MINGW." am: ec99158580 am: 2e7e065db9
am: 04819403d6

Change-Id: I03fc482f4d0aab72991b351e855b8e240ed3abd9
2016-10-05 18:38:10 +00:00
Elliott Hughes
04819403d6 Merge "Test for _WIN32 in instead of USE_MINGW." am: ec99158580
am: 2e7e065db9

Change-Id: I9c7bee42bf1d7522d4dd95b5bb8a925841f96624
2016-10-05 18:35:40 +00:00
Treehugger Robot
ec99158580 Merge "Test for _WIN32 in instead of USE_MINGW." 2016-10-05 18:30:06 +00:00
Elliott Hughes
34a4f0b8c7 Test for _WIN32 in instead of USE_MINGW.
Bug: http://b/23392815
Test: builds
Change-Id: I7fce8de1f0e2314170cce456cd49346dcee9d134
2016-10-05 09:37:44 -07:00
Mark Salyzyn
74ba3b0ce6 Merge "system/core: drop or replace log/logger.h" am: 1f90485804 am: cb670780be
am: 6e5ffe2680

Change-Id: I4c1351fb61b3357d059a8e1da4ce14e3701e17af
2016-10-04 18:37:14 +00:00
Mark Salyzyn
6e5ffe2680 Merge "system/core: drop or replace log/logger.h" am: 1f90485804
am: cb670780be

Change-Id: I532a0f6143511f53f3303751f95de115ac034cd7
2016-10-04 18:33:44 +00:00
Mark Salyzyn
37c9451349 system/core: drop or replace log/logger.h
debuggerd does not require log/logger.h, can use android/log.h
In some cases, mark why log/logger.h was required.

Test: Compile and boot smoke test
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: Ia34987e25a01d81971ec8d785415f732b8376c4f
2016-10-04 09:09:10 -07:00
Mohan Srinivasan
96eba22338 Merge "liblog: logd: Add android_lookupEventTag_len()" am: 093951a230 am: aed39f1f3d
am: 2acb41b46c

Change-Id: Ifd5da3780cf05863b71fad9583b1b83f4962b46f
2016-10-03 22:47:51 +00:00
Mohan Srinivasan
2acb41b46c Merge "liblog: logd: Add android_lookupEventTag_len()" am: 093951a230
am: aed39f1f3d

Change-Id: If1615c62df20df58eda2910455f2a1e05268fba7
2016-10-03 22:42:20 +00:00
Mark Salyzyn
807e40ecc9 liblog: logd: Add android_lookupEventTag_len()
Allows us to mitigate the impact of MAP_PRIVATE and copy on write by
calling android_lookupEventTag_len instead of android_lookupEventTag,
and delaying the copy on write impact to the later.  We return a
string length in a supplied location along with the string pointer
with android_lookupEventTag_len(const EventTagMap* map, size_t* len,
int tag).  The string is not guaranteed to be nul terminated.  Since
android_lookupEventTag() called even once can cause the memory
impact, we will mark it as deprecated, but we currently have no
timeframe for removal since this is a very old interface.

Add an API for __android_log_is_loggable_len() that accepts the non
null terminated content and fixup callers that would gain because the
length is known prior to the call either in the compiler or at
runtime.  Tackle transition to android_lookupEventTag_len() and
fixup callers.

On any application that performs logging (eg: com.android.phone)

/proc/<pid>/smaps before:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 463 /system/etc/event-log-tags
Size:                 20 kB
Rss:                  20 kB
Pss:                   1 kB
Shared_Clean:          0 kB
Shared_Dirty:         20 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:            0 kB
Anonymous:            20 kB
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac

/proc/<pid>/smaps after:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 1773 /system/etc/event-log-tags
Size:                 20 kB
Rss:                  20 kB
Pss:                   1 kB
Shared_Clean:         20 kB  (was 0kB)
Shared_Dirty:          0 kB  (was 20kB)
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:           20 kB  (was 0kB)
Anonymous:             0 kB  (was 20kB)
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac

Added liblog-unit-tests --gtest_filter=liblog.event_log_tags to
check for Shared_Clean: to not be 0 and Anonymous: to be 0 for
all processes referencing event-log-tags.  Which can include multiple
references to /system/etc/event-log-tags and future possible refs to
/data/misc/logd/event-log-tags and /dev/event-log-tags.  We want
failure messages to help point to errant code using the deprecated
interface.

This change saves 1/4MB of memory or more on a typical system.

Test: gTest liblog-unit-tests
Bug: 31456426
Change-Id: I9e08e44d9092bd96fe704b5709242e7195281d33
2016-10-03 11:08:34 -07:00
Mark Salyzyn
9f6b98dec0 system/core Replace log/log.h with android/log.h am: ff2dcd9af9 am: cac331afd9
am: 0308b0eabd

Change-Id: I4d631d53b4fc27e1a02d412bae21fffad6635258
2016-09-30 22:18:18 +00:00
Mark Salyzyn
0abff8fc61 system/core Replace cutils/log.h with android/log.h am: 66ce3e08c5 am: eb189f147b
am: 16f7786032

Change-Id: I26939d55686b6182c9fae5fc74f3e7ed92132cdb
2016-09-30 22:18:03 +00:00
Mark Salyzyn
9bb1f2f915 libcutils: Replace cutils/log.h with android/log.h am: 23ed4c242a am: f56fce0240
am: 9fd2eaf827

Change-Id: If01fd686fc15aaf74b6f06b7e661eb46e127d51b
2016-09-30 22:17:30 +00:00
Mark Salyzyn
2156aae1d5 liblog: Replace log/log.h with android/log.h am: 6584d0a35a am: 499a33d6dc
am: c528ac0fe8

Change-Id: I2e6eb5782ccd27e47e8302381d790611fd58a1d7
2016-09-30 22:17:20 +00:00
Mark Salyzyn
ea3c6d1029 liblog: logcat: Replace log/logd.h with log/log.h am: a166708d15 am: 772ed1c63c
am: 2b42b87d8c

Change-Id: I4a977e248d0ea7e3b8ed31aed0643752aaab4e1c
2016-09-30 22:17:14 +00:00
Mark Salyzyn
a06a6509d9 liblog: logd: logcat: deprecate log/log_read.h am: 004cd3c55d am: 78a459a8c8
am: 13c68b09d9

Change-Id: Icaab3eedecad8f55d8d1291b3414da5c12cec287
2016-09-30 22:17:08 +00:00
Mark Salyzyn
519bdbf0b4 liblog: Add C++ wrapper for C event log handler am: 8eaaac0103 am: 8b4cab3f69
am: 848da90978

Change-Id: I215d1da28c1d4e0377097f49493d1e9c5fc9ee75
2016-09-30 22:17:02 +00:00
Mark Salyzyn
0308b0eabd system/core Replace log/log.h with android/log.h am: ff2dcd9af9
am: cac331afd9

Change-Id: I95c6a64bc35a041688303fcee4d506865d0a19a4
2016-09-30 22:13:00 +00:00
Mark Salyzyn
16f7786032 system/core Replace cutils/log.h with android/log.h am: 66ce3e08c5
am: eb189f147b

Change-Id: I3f2b13e259d9bbb7bc714f21eab7181fa72c35bf
2016-09-30 22:12:55 +00:00
Mark Salyzyn
9fd2eaf827 libcutils: Replace cutils/log.h with android/log.h am: 23ed4c242a
am: f56fce0240

Change-Id: I588c3a252594e1ecd4b34242217cf23c84e4af67
2016-09-30 22:12:45 +00:00
Mark Salyzyn
c528ac0fe8 liblog: Replace log/log.h with android/log.h am: 6584d0a35a
am: 499a33d6dc

Change-Id: If28b70b199b4bbf99f853d6c6d14b73a72fafacb
2016-09-30 22:12:41 +00:00
Mark Salyzyn
2b42b87d8c liblog: logcat: Replace log/logd.h with log/log.h am: a166708d15
am: 772ed1c63c

Change-Id: Ibd14ac6a57994019e188e6ec138682b50d1f7e69
2016-09-30 22:12:36 +00:00
Mark Salyzyn
13c68b09d9 liblog: logd: logcat: deprecate log/log_read.h am: 004cd3c55d
am: 78a459a8c8

Change-Id: If1a76043e7941191b3c6ba07ca0277b7f9b7f2e6
2016-09-30 22:12:32 +00:00
Mark Salyzyn
848da90978 liblog: Add C++ wrapper for C event log handler am: 8eaaac0103
am: 8b4cab3f69

Change-Id: I2760c8480818f30dd126e7cfbb900a0f5796c8b1
2016-09-30 22:12:28 +00:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/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: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
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
Mark Salyzyn
23ed4c242a libcutils: Replace cutils/log.h with android/log.h
Replace references to cutils/log.h and log/log.h with android/log.h.
Point cutils/log.h to android/log.h. Adjust header order to comply
with Android Coding standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I4b00c0dff3a0a50cbb54301fdc5a6c29c21dab65
2016-09-30 12:47:05 -07:00
Mark Salyzyn
6584d0a35a liblog: Replace log/log.h with android/log.h
Move all liblog related content into android/log.h, and make
log/log.h points to android/log.h.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I858e0ebe047b86f2a8530a99bc9c380d3d58edbb
2016-09-30 12:47:05 -07:00
Mark Salyzyn
a166708d15 liblog: logcat: Replace log/logd.h with log/log.h
Should use log/log.h and in some cases android/log.h instead. Can
not remove file because still in use by partners, so log/logd.h
points to log/log.h.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I3580d46154617abb7231027a44f4ab9ee023febf
2016-09-30 12:47:05 -07:00
Mark Salyzyn
004cd3c55d liblog: logd: logcat: deprecate log/log_read.h
Always used in combination with log/logger.h except in log_time.cpp,
and not used externally.  As a result liblog has to support stl, a
small price to pay since goal is to convert liblog to C++ internally.

Test: compile
Bug: 31456426
Bug: 26552300
Bug: 31289077
Change-Id: I72828ec807d0a2c8e40bbdebd7a69f147a7ca5a9
2016-09-30 12:47:05 -07:00
Mark Salyzyn
8eaaac0103 liblog: Add C++ wrapper for C event log handler
Add android_log_event_context class.

Test: in context of 'logd: add getEventTag command and service'
Bug: 31456426
Bug: 26552300
Bug: 31289077
Bug: 19235719
Change-Id: Icf918b443f01e04040c8d3efe0cdb7a8e70be10c
2016-09-30 12:47:05 -07:00
Miodrag Dinic
53be7eb3d0 Merge "[qemu]: Fix payload size format in qemu_pipe_frame_send()" am: e5976bea7a am: 8c274361fb
am: f610eaac14

Change-Id: I890fbb885044e82d4ec66a5a400240124003ac25
2016-09-30 18:00:16 +00:00
Miodrag Dinic
f610eaac14 Merge "[qemu]: Fix payload size format in qemu_pipe_frame_send()" am: e5976bea7a
am: 8c274361fb

Change-Id: I7c80343b0002ec68ef9cde40dad2202aa9b70c00
2016-09-30 17:49:11 +00:00
Miodrag Dinic
192be1dcae [qemu]: Fix payload size format in qemu_pipe_frame_send()
The following change introduced regression for booting AOSP
on emulator for all architectures:

7c7990e Fix warnings in system/ headers

qemu_pipe expects payload size in the message header to be in hex format,
as stated in the comment for qemu_pipe_frame_send().

Change-Id: I32cfa9c9b2af56f93bbda0ea5597451c389ae45e
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
2016-09-30 13:58:11 +02:00
Colin Cross
0763c30289 Merge "Fix more system/core/include warnings" am: 18fbd80504 am: 5fe194a9fd
am: b5ca47989c

Change-Id: I8d5a602f94bc57866aa3827cc508c94afb4ac4ba
2016-09-29 17:58:08 +00:00
Colin Cross
b5ca47989c Merge "Fix more system/core/include warnings" am: 18fbd80504
am: 5fe194a9fd

Change-Id: I8e561ab27f93ed10efa8a0e864cd7d1283bb6163
2016-09-29 17:42:19 +00:00
Colin Cross
18fbd80504 Merge "Fix more system/core/include warnings" 2016-09-29 17:20:30 +00:00
Mark Salyzyn
ae1612c54c Merge "liblog: fix errno issues with event tag map" am: dfd30c4a16 am: 930ff186ce
am: 71b38def04

Change-Id: I83de9e374a67946fde8191d63720b102690d468f
2016-09-28 18:21:01 +00:00
Mark Salyzyn
71b38def04 Merge "liblog: fix errno issues with event tag map" am: dfd30c4a16
am: 930ff186ce

Change-Id: Iac84f40e9e79063bee7f213eb21ff5f866462a32
2016-09-28 18:17:49 +00:00
Colin Cross
1811d156e9 Fix more system/core/include warnings
The warnings in these files were hidden by -isystem
framework/native/include.

Bug: 31752268
Test: m -j
Change-Id: I2a54376aea380ee24e6483fb7d35fdfe8991c490
2016-09-27 16:21:12 -07:00
Mark Salyzyn
70a83dc7b3 liblog: fix errno issues with event tag map
Cleanup.

Save the errno for the calls that fail, and reinstate them for
return. Drop fprintf stutter, one succinct line. Solve a memory
leak in close.  Change android_lookupEventTag() to use an
unsigned int so that we can use the full range of uint32_t tags.

Make sure this file compiles clean in C++.

Test: gTest liblog-unit-tests
Bug: 30963384
Bug: 31456426
Change-Id: I6a5efa6fb7e991431caba75ef0971e111968f6bf
2016-09-26 09:23:55 -07:00
Chia-I Wu
fd3ea3d118 Add native_handle_clone
libhwbinder's Parcel::readNativeHandleNoDup returns a temporary
native_handle_t.  We want a way to save the temporary handle for later
use.

Change-Id: I16f32043aa8b7d2c0aa57d67551500259b411410
2016-09-26 21:59:04 +08:00
David Pursell
7bc0052ff1 Merge "Flattenable: switch from assignment to memcpy()." am: b2356a6993 am: bb276d8555
am: 9f106bece8

Change-Id: I43e4e5c6bb0aa1fd23a1d0d9776c9e2c8028527e
2016-09-23 22:56:01 +00:00
David Pursell
9f106bece8 Merge "Flattenable: switch from assignment to memcpy()." am: b2356a6993
am: bb276d8555

Change-Id: I2d7317f601dcfc85705f2e71408c314de55a0f69
2016-09-23 22:53:48 +00:00
David Pursell
b2356a6993 Merge "Flattenable: switch from assignment to memcpy()." 2016-09-23 22:46:03 +00:00
Colin Cross
8e3427fb04 Merge "Move android_get_control_socket out of line" am: 4b5abcdba2 am: 4873829953
am: ea2b61c7a8

Change-Id: Ib406546b998d6d525829f0023a5f693c2e1dfd6c
2016-09-23 21:00:41 +00:00
Colin Cross
ea2b61c7a8 Merge "Move android_get_control_socket out of line" am: 4b5abcdba2
am: 4873829953

Change-Id: I45e8b86e43a47213664acf486a5de266bab6deb8
2016-09-23 20:58:40 +00:00
David Pursell
2ebce7384b Flattenable: switch from assignment to memcpy().
FlattenableUtils read() and write() currently use assignment to copy
bytes. However, by casting the void* buffer to type T, the compiler is
allowed to assume that buffer obeys the alignment requirements of T,
which is not necessarily the case during serialization. On some
architectures, we can get SIGBUS when this alignment is violated.

We don't want the users of these routines to have to worry about
alignment when packing structures, so use memcpy() instead which should
always be safe since the compiler won't assume any alignment for the
void* buffer.

On architectures that can handle unaligned direct read/write of type T,
the compiler should be smart enough to optimize this code back to a
direct read/write anyway, but architectures that can't handle it will
fall back to memcpy; this means that this change shouldn't have any
impact on current Android devices. See the linked bug for more details.

Bug: http://b/31671510
Test: libgui Sensor serialization no longer gives SIGBUS.
Test: libgui.so unchanged on Shamu before and after this CL.
Change-Id: I2197127e8cbfb43f4f553bda6464f6ebe087febd
2016-09-23 13:56:40 -07:00
Colin Cross
e8ffa449fd Move android_get_control_socket out of line
android_get_control_socket has a warning from the implicit cast from
long to int.  The warning was being hidden because cutils/sockets.h was
included with -isystem.  Move android_get_control_socket to sockets.cpp,
since we don't want header only dependencies anyways, and fix the
warning with a range check and a static_cast.

Bug: 31492149
Test: m -j <module that uses sockets.h and -Wall>
Change-Id: I1f394ab26d4ec8a7dd0e7907c10416d7f8647624
2016-09-23 11:26:08 -07:00
Colin Cross
28cda0bf38 Merge "Fix warnings in libutils headers" am: 65a1633ec3 am: 0f79b62bf6
am: 1446cbac58

Change-Id: I94a39bb24224218ef1c48080ace3455c1fc7233a
2016-09-22 23:04:13 +00:00
Colin Cross
021899fa8a Merge "Remove has_trivial_move trait from Vector<T>" am: 588b3b0c03 am: 85942090f6
am: 749181c10b

Change-Id: Ie339e0ea27463d0c5b093e9a5e262367d1ca57a5
2016-09-22 22:58:13 +00:00
Colin Cross
bd45ba6972 Merge "Fix warnings in system/ headers" am: d7f60fd871 am: 299df0bf01
am: 88fd7e2ec4

Change-Id: I94891ea3c3a00ee39b48531fcc8e5e3d6ebe724a
2016-09-22 22:52:44 +00:00
Colin Cross
1446cbac58 Merge "Fix warnings in libutils headers" am: 65a1633ec3
am: 0f79b62bf6

Change-Id: I62fea8f4ed3f2a9d16d68539eb073965531944da
2016-09-22 22:51:15 +00:00
Ajay Panicker
531b201eb6 Merge "Remove net_bt_stack group and replace it with bluetooth" am: 7875407bb7 am: f924c252bd
am: b0db9714bb

Change-Id: I025c5301fecf0566d8184efce099a195fdbfc460
2016-09-22 21:58:27 +00:00
Colin Cross
749181c10b Merge "Remove has_trivial_move trait from Vector<T>" am: 588b3b0c03
am: 85942090f6

Change-Id: Ic41410047760bff11063d12839921ae008fe7e65
2016-09-22 20:33:40 +00:00
Colin Cross
17b5b82d64 Fix warnings in libutils headers
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in libutils
headers in preparation for moving from -isystem to -I.

- Fix implicit cast from int64_t to long in Condition.h.  Remove
  the __LP64__ check and always compare against LONG_MAX before
  casting.
- Fix implicit cast from size_t to ssize_t in KeyedVector.h
- Fix -Wshadow-field-in-constructor warnings in Looper.h and RefBase.h
- Move destructors for MessageHandler and LooperCallback to Looper.cpp
  and ReferenceRenamer and VirtualLightRefBase to RefBase.cpp to prevent
  vtables in every compilation unit.
- Declare template variables in Singleton.h
- Fix old-style casts in StrongPointer.h and TypeHelpers.h
- Use template metaprogramming in TypeHelpers.h to avoid warnings on
  memmove on non-trivial types.
- Add an assignment operator to key_value_pair_t to complete
  rule-of-three
- Use memcpy instead of dereferencing a reinterpret_casted pointer to
  treat the bits of a float or double as int32_t or int64_t
- Escape unicode sequences inside doxygen comments between \code and
  \endcode
- Remove WIN32 ZD definition in Compat.h, %zd works fine with mingw
- Fix WIN32 printf warnings in Filemap.cpp
- Initialize mNullValue with 0 in LruCache.h, some of the tests use a
  non-pointer type for TValue.

Test: m -j native
Bug: 31492149
Change-Id: I385a05a3ca01258e44fe3b37ef77e4aaff547b26
2016-09-22 13:03:15 -07:00
Colin Cross
588b3b0c03 Merge "Remove has_trivial_move trait from Vector<T>" 2016-09-22 19:44:28 +00:00
Colin Cross
097395532b Remove has_trivial_move trait from Vector<T>
Vector<T> objects are a dynamic type with a vtable, which is not
trivially moveable.

Impact on aapt for frameworks-res is negligible, ~3%.

Bug: 31595853
Test: m -j framework-res
Change-Id: I8a3269c35d95affb6e86d60588bcfca46db7f445
2016-09-22 10:14:05 -07:00
Colin Cross
88fd7e2ec4 Merge "Fix warnings in system/ headers" am: d7f60fd871
am: 299df0bf01

Change-Id: Ie6b83fdc3b97601e1021b104d4b42eec6b30bfc4
2016-09-22 11:54:20 +00:00
Ajay Panicker
b0db9714bb Merge "Remove net_bt_stack group and replace it with bluetooth" am: 7875407bb7
am: f924c252bd

Change-Id: I99e0ed5e52c71b2e41e54faf03678e57a853d140
2016-09-22 11:23:53 +00:00
Colin Cross
7673c4dc88 Merge "Hide warning in cutils/trace.h" am: 5cf3db6d2b am: a802e570b3
am: 06ec4b1352

Change-Id: If41d5b551ffe237922f4768cf403cadf7ee15887
2016-09-22 09:15:21 +00:00
Colin Cross
e84c07c832 Merge "Hide gnu extension warnings in log/log.h" am: 21049e5c91 am: 9eb3592e62
am: 4df8e4580b

Change-Id: I18d466cf45327b96856e2fb2c0ec7954a675987a
2016-09-22 09:15:06 +00:00
Treehugger Robot
d7f60fd871 Merge "Fix warnings in system/ headers" 2016-09-22 02:46:51 +00:00
Ajay Panicker
7875407bb7 Merge "Remove net_bt_stack group and replace it with bluetooth" 2016-09-22 01:32:34 +00:00
Colin Cross
06ec4b1352 Merge "Hide warning in cutils/trace.h" am: 5cf3db6d2b
am: a802e570b3

Change-Id: I216420b21d71087b2e3a5bc864f9d419270dc749
2016-09-22 01:02:40 +00:00
Colin Cross
4df8e4580b Merge "Hide gnu extension warnings in log/log.h" am: 21049e5c91
am: 9eb3592e62

Change-Id: I3c155d9b0ca9f5e87e35159e578fbe91af0ed4ec
2016-09-22 01:02:27 +00:00
Colin Cross
7c7990e6fd Fix warnings in system/ headers
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in
system/core/include/system in preparation for moving from -isystem to -I.

- Fix invalid doxygen syntax in graphics.h
- Use a pragma to hide a C99 extension warning on the flexible length
  array in graphics.h
- Make static functions in radio.h static inline
- Fix size_t printf and size_t vs. ssize_t comparision in qemu_pipe.h
- Fix old style cast in window.h

Test: m -j native
Bug: 31492149
Change-Id: I857f289e4c8e303494831873282bbb69de155c10
2016-09-21 17:46:59 -07:00
Colin Cross
5cf3db6d2b Merge "Hide warning in cutils/trace.h" 2016-09-22 00:46:13 +00:00
Colin Cross
9993e799f1 Hide warning in cutils/trace.h
system/core/include is included in the global include path using
-isystem, which hides all warnings.  cutils/trace.h has an ignored
return value warning, move the implementation to trace-dev.c so it
doesn't cause warnings in every module that includes it in preparation
for moving from -isystem to -I.

Test: m -j native
Bug: 31492149
Change-Id: If8b3fe13059c9e59c2d5208294d427d84fa6e588
2016-09-21 17:45:31 -07:00
Colin Cross
21049e5c91 Merge "Hide gnu extension warnings in log/log.h" 2016-09-22 00:45:02 +00:00
Ajay Panicker
604208e957 Remove net_bt_stack group and replace it with bluetooth
Bug: 31549206
Change-Id: I667963e5f9fd1a5dc9ad74378b318e3b782e6883
2016-09-20 12:01:33 -07:00
Colin Cross
bcedc20a2e Merge "Fix warnings in libziparchive" am: 91811d2d34 am: 6f5edc78d8
am: e3d8246c0b

Change-Id: I4737599a4245d4ed1b8c6c77ff939fee1e206f86
2016-09-20 18:47:46 +00:00
Colin Cross
e3d8246c0b Merge "Fix warnings in libziparchive" am: 91811d2d34
am: 6f5edc78d8

Change-Id: I3f2869a94cebaf86647443bdc7a2f3520e5dd555
2016-09-20 18:37:19 +00:00
Colin Cross
7c6c7f0b9f Fix warnings in libziparchive
system/core/include is included in the global include path using
-isystem, which hides all warnings.  zlib.h is included through
system/core/include/ziparchive/zip_archive.h, which was hiding warnings
in it.  Use a #pragma around the call to deflateInit2, it is a macro
that expands to an old-style cast, in preparation for moving from
-isystem to -I.  Also move the ZipString constructor to zip_archive.cc
so it can assert on the length of the string parameter and fix an
implicit conversion from size_t to uint16_t.

Test: m -j native
Bug: 31492149
Change-Id: I74cdad7fe9c723859b5cfbea73c8f27d9d9ca265
2016-09-20 09:23:47 -07:00
Elliott Hughes
c6dd9aaf5c Move libusbhost's headers into libusbhost. am: e0a7c773ed am: d141edfb3c
am: 1cde9655bb

Change-Id: I2df83b58943ca2ffe3f82ba7199ae85976f169c8
2016-09-17 01:43:40 +00:00
Elliott Hughes
1cde9655bb Move libusbhost's headers into libusbhost. am: e0a7c773ed
am: d141edfb3c

Change-Id: I3eed13355c67ff09b6f61aee5b6329ec15ce8b21
2016-09-17 01:41:09 +00:00
Elliott Hughes
d141edfb3c Move libusbhost's headers into libusbhost.
am: e0a7c773ed

Change-Id: Ia6b0131c9405650a8c9934a7010c7723f028f6dd
2016-09-17 01:38:39 +00:00
Treehugger Robot
36b88ce975 Merge "Move libusbhost's headers into libusbhost." 2016-09-17 01:33:11 +00:00
Colin Cross
3b7524fe3a Merge "Fix warnings in cutils/atomic.h" am: 5e093f367c am: 6f292bcab9
am: a205ed0aad

Change-Id: I03b1bcf695452b7f0322aaa166c2fe64fc0b49bb
2016-09-16 20:08:56 +00:00
Colin Cross
a205ed0aad Merge "Fix warnings in cutils/atomic.h" am: 5e093f367c
am: 6f292bcab9

Change-Id: I69dc6ea6ec78f48710be69e287f1610726894466
2016-09-16 19:47:31 +00:00
Treehugger Robot
5e093f367c Merge "Fix warnings in cutils/atomic.h" 2016-09-16 19:31:10 +00:00
Colin Cross
412ad0dad8 Hide gnu extension warnings in log/log.h
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in log/log.h
in preparation for moving from -isystem to -I.

log/log.h uses gnu extensions for zero-argument variadic macro token
pasting, which clang warns about with -Weverything.  Hide the warnings
using pragmas.

Test: m -j native
Bug: 31492149
Change-Id: Ib2113f877d811a6ecc0e91c035640b506f04bd86
2016-09-16 11:13:20 -07:00
Elliott Hughes
ab273a5a4b Move libbinderwrapper's headers into libbinderwrapper. am: 40104501fa am: c5cc029993
am: 761c529b37

Change-Id: Iabb74f1a8ea0c79821b2ee3efbfce4bfbccbac13
2016-09-16 18:04:57 +00:00
Elliott Hughes
761c529b37 Move libbinderwrapper's headers into libbinderwrapper. am: 40104501fa
am: c5cc029993

Change-Id: I351680f306d7fb8814f8b41eb9e895a1a4153827
2016-09-16 17:51:24 +00:00
Elliott Hughes
e0a7c773ed Move libusbhost's headers into libusbhost.
Change-Id: Ic5ff65bd6456ea3cc92e0c8f9d7a6f499e58dbfc
2016-09-16 10:43:56 -07:00
Elliott Hughes
40104501fa Move libbinderwrapper's headers into libbinderwrapper.
It was probably the LOCAL_EXPORT_C_INCLUDE_DIRS that made me miss this on the
original code review...

Change-Id: I55bc0b0698604338cd206bf5f336798929b6d8f9
2016-09-16 09:02:47 -07:00
Colin Cross
ec69c05463 Fix warnings in cutils/atomic.h
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in cutils/atomic.h in
preparation for moving from -isystem to -I.

Test: m -j native
Bug: 31492149
Change-Id: I2a212f192309090a16d507e9ab6acf0fd7cac02d
2016-09-15 19:22:32 -07:00
Courtney Goeltzenleuchter
7ae63a8cbd Add color mode enums am: a2e874eabc
am: ae93122c0e

Change-Id: Ifaef323f9804c36ca5271fd3eafcef75cf67e9c5
2016-09-09 18:47:13 +00:00
Lajos Molnar
ef8322329e add android_flex_layout for describing all flexible formats. am: 0e10df4dd6
am: a2d46813fc

Change-Id: I47fbc1c78ac1458150d5231a85b4cf5c3e17a62f
2016-09-09 18:47:07 +00:00
Courtney Goeltzenleuchter
a2e874eabc Add color mode enums
The android_color_mode_t defines the color modes supported
by a display. A display can support multiple different
color modes.

sRGB mode and AdobeRGB are deliberately placed at 7 and 8
so that they match mode ID's used on prior devices.

bug: http://b/27926012
Change-Id: I9ab41b56ec0b495c02539665da5be158ffddf843
2016-09-08 11:39:32 -07:00
Lajos Molnar
0e10df4dd6 add android_flex_layout for describing all flexible formats.
Bug: 22767098
Bug: 24759202
Change-Id: I61e4ca9bd71e8da88a9571ec4effc7165026715b
2016-09-08 11:38:53 -07:00
Felipe Leme
c561b35f29 Added a NETWORK trace tag. am: 785735bde1
am: 860f100454

Change-Id: I729a74de3a1da6cbf176e33dfda253ac47d4dfd8
2016-09-08 00:44:48 +00:00
Felipe Leme
785735bde1 Added a NETWORK trace tag.
BUG: 31281543
Change-Id: I4d7c7fc26c77fec099bbf0f9426e3a9f3a722e6d
2016-09-07 12:47:18 -07:00
Mark Salyzyn
2fb3f08d51 liblog: add __android_log_close()
Bug: 30963384

(cherry picked from commit df7a4c6bae)

Change-Id: Iee7cd0db819644299fa086586630e71415643294
2016-08-30 16:02:08 +01:00
Christopher Ferris
0c572d01af Fix race condition updating local map data.
If the underlying local map changes, it's possible for multiple
threads to try and modify the map data associated with the UnwindLocalMap
object. Add a lock when generating the local map to avoid this problem.

In addition, add a read lock whenever any caller gets the maps iterator.
Updated all iterator callers to make this lock.

Bug: 29387050
Bug: 31067025

(cherry picked from commit 3a14004c7f)

Change-Id: Id00116f156a24b36085c0d5dfc3dde4d2ac55194
2016-08-25 15:01:53 -07:00
Martijn Coenen
111ef54a28 Merge changes from topic 'utf' am: 3a07e5bf94 am: aa7fd8a3ec
am: ade3876260

Change-Id: Ifec806c7553b36a6502a8b5bb3dec559c117f4cc
2016-08-25 20:31:42 +00:00
Martijn Coenen
ade3876260 Merge changes from topic 'utf' am: 3a07e5bf94
am: aa7fd8a3ec

Change-Id: I3c90317d492a84ff99b18463d6f489e7b1cca61b
2016-08-25 20:24:14 +00: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
2d3545fe82 Merge "Make RefBase more robust and debuggable" am: daac359be7 am: 7bf3d21fde
am: 7dddf9433c

Change-Id: Ia8bdef250b29d964a9ab07c450da31a368bb3143
2016-08-24 23:52:14 +00:00
Hans Boehm
7dddf9433c Merge "Make RefBase more robust and debuggable" am: daac359be7
am: 7bf3d21fde

Change-Id: I643c4bd38062b80d382c50ed161f5440f35c1dd9
2016-08-24 23:49:14 +00:00
Hans Boehm
daac359be7 Merge "Make RefBase more robust and debuggable" 2016-08-24 23:36:13 +00:00
Andy Hung
8ec6753d61 Fix Mutex::timedLock to properly handle relative time am: 604ba48220 am: 708b9d118a
am: 47e5ca61e2

Change-Id: I5c351fbdc485acbcb33426b99ea6b900519ee0e3
2016-08-24 22:50:00 +00:00
Andy Hung
604ba48220 Fix Mutex::timedLock to properly handle relative time
Bug: 31008450
Change-Id: Ie6c17e17b7a8c3d8a087c47be535e9d04f285380
2016-08-24 22:29:11 +00:00
Mark Salyzyn
e5bda4d0ec Merge "liblog: add __android_log_close()" am: 812d1c7ea2 am: 6322efe522
am: ed421af68d

Change-Id: Ifacd3de810c30a9b79cb262ab4c2432d8b1c0791
2016-08-24 16:10:09 +00:00
Mark Salyzyn
af3623281f Merge "logger: validate hdr_size field in logger entry" am: fcf7ab8b1b am: 2d562c9dce
am: 098b5887c6

Change-Id: I4d067039a766e7079a91eb56d2ffb8d68aba58b5
2016-08-24 16:10:08 +00:00
Mark Salyzyn
ed421af68d Merge "liblog: add __android_log_close()" am: 812d1c7ea2
am: 6322efe522

Change-Id: Ib61d4ec5102fcfb12c48250c019fcdf019c2ffc5
2016-08-24 16:07:39 +00:00
Mark Salyzyn
098b5887c6 Merge "logger: validate hdr_size field in logger entry" am: fcf7ab8b1b
am: 2d562c9dce

Change-Id: I5721e8614079a04c2dc364304d0ffed10d74be90
2016-08-24 16:07:38 +00:00
Mark Salyzyn
6322efe522 Merge "liblog: add __android_log_close()"
am: 812d1c7ea2

Change-Id: I2ba5ed22e78564a864bab6b550b6d2bd2609a629
2016-08-24 16:05:05 +00:00
Mark Salyzyn
2d562c9dce Merge "logger: validate hdr_size field in logger entry"
am: fcf7ab8b1b

Change-Id: Ic88fe616256ab4949040771d3bed1dfb823ab981
2016-08-24 16:05:04 +00:00
Treehugger Robot
812d1c7ea2 Merge "liblog: add __android_log_close()" 2016-08-24 15:58:48 +00:00
Treehugger Robot
fcf7ab8b1b Merge "logger: validate hdr_size field in logger entry" 2016-08-24 15:56:23 +00:00
Mark Salyzyn
8e5cb037c4 Merge "libcutils: Add ashmem_valid() function" am: d00c7470ea am: 8b1f7b595c
am: da07f7880c

Change-Id: I3a4cf9a2cd848aae04ec3e88ae1e50a51774cd5f
2016-08-24 15:54:08 +00:00
Mark Salyzyn
da07f7880c Merge "libcutils: Add ashmem_valid() function" am: d00c7470ea
am: 8b1f7b595c

Change-Id: I1be0fc5d74c609ec42578c29c7af9d897708f8c6
2016-08-24 15:51:08 +00:00
Mark Salyzyn
8b1f7b595c Merge "libcutils: Add ashmem_valid() function"
am: d00c7470ea

Change-Id: Ib09d3ee7bb131c30f59ea273f357c045394206fb
2016-08-24 15:48:55 +00:00
Mark Salyzyn
ee431112ff libcutils: Add ashmem_valid() function
Bug: 30310689
Change-Id: I14c52c5d52745a725799652b87c86281ac214899
2016-08-23 15:29:28 -07:00
Mark Salyzyn
df7a4c6bae liblog: add __android_log_close()
Bug: 30963384
Change-Id: I901e6ac2cc3c601bbecc2d64e00a98e2ab448210
2016-08-23 15:25:03 -07:00
Mark Salyzyn
305374cf0f logger: validate hdr_size field in logger entry
- check hdr_size to make sure it is in the expected range
  from sizeof entry_v1 to entry (entry_v4).
- alter msg() method to report NULL on invalid hdr_size
- alter all users of msg() method.

Bug: 30947841
Change-Id: I9bc1740d7aa9f37df5be966c18de1fb9de63d5dd
2016-08-23 14:51:50 -07:00
Connor O'Brien
7d7f5399d4 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a am: b906ad88b9 am: 2fadbb93a4 am: e04054d9bb am: 9745b11db1 am: 2f78b2c3d6 am: 2b5e6d8ffc am: 2427a462c0 am: 6b155c1cc4 am: 2f16eeede6
am: 233c9902cf

Change-Id: Idc2f2b967a890489769cda203d8ed7b73eb6a303
2016-08-19 22:57:38 +00:00
Connor O'Brien
233c9902cf Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a am: b906ad88b9 am: 2fadbb93a4 am: e04054d9bb am: 9745b11db1 am: 2f78b2c3d6 am: 2b5e6d8ffc am: 2427a462c0 am: 6b155c1cc4
am: 2f16eeede6

Change-Id: I3d2fdfc10f91080ca32aa6557b13391355427edc
2016-08-19 22:53:32 +00:00
Connor O'Brien
af8d67e032 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a am: b906ad88b9 am: 2fadbb93a4 am: e04054d9bb am: 9745b11db1 am: 2f78b2c3d6 am: 2b5e6d8ffc am: 2427a462c0 am: 6b155c1cc4
am: 2f16eeede6

Change-Id: I272469151a3680acfc2203a0f3aac79a319a1d06
2016-08-19 22:53:32 +00:00
Connor O'Brien
2f16eeede6 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a am: b906ad88b9 am: 2fadbb93a4 am: e04054d9bb am: 9745b11db1 am: 2f78b2c3d6 am: 2b5e6d8ffc am: 2427a462c0
am: 6b155c1cc4

Change-Id: Ie6c2bcee1deacb94259a6153097757674fa19251
2016-08-19 22:50:00 +00:00
Connor O'Brien
2f78b2c3d6 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a am: b906ad88b9 am: 2fadbb93a4 am: e04054d9bb
am: 9745b11db1

Change-Id: I61f685976803f51db9ba85729554fc14efaa4b2c
2016-08-19 22:36:29 +00:00
Connor O'Brien
9745b11db1 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a am: b906ad88b9 am: 2fadbb93a4
am: e04054d9bb

Change-Id: Ia5f46e5b9622946ca0e44fbe7399729807d2d08a
2016-08-19 22:34:46 +00:00
Connor O'Brien
2fadbb93a4 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c am: 109024f74a
am: b906ad88b9

Change-Id: Ida2b33bd1db284dfa8ad3f130219481a92785e97
2016-08-19 22:14:57 +00:00
Connor O'Brien
b906ad88b9 Fix vold vulnerability in FrameworkListener am: 470484d2a2 am: e9e046df6c
am: 109024f74a

Change-Id: Ia6e8dca36bc28d442a6e374ecf033b79176f4b93
2016-08-19 22:11:27 +00:00
Connor O'Brien
109024f74a Fix vold vulnerability in FrameworkListener am: 470484d2a2
am: e9e046df6c

Change-Id: I8f2452782817ddf03051af08e70ba9d4c4fa578a
2016-08-19 22:08:22 +00:00
Connor O'Brien
470484d2a2 Fix vold vulnerability in FrameworkListener
Modify FrameworkListener to ignore commands that exceed the maximum
buffer length and send an error message.

Bug: 29831647
Change-Id: I9e57d1648d55af2ca0191bb47868e375ecc26950
Signed-off-by: Connor O'Brien <connoro@google.com>
(cherry picked from commit baa126dc15)
2016-08-19 17:05:25 +00:00
Dmitriy Filchenko
ceca7afbc7 Merge "Remove process_name.c" am: e5b7ad1c39 am: 97e3cb7074
am: de9e6fb4b0

Change-Id: I402ab55567532786d61412e7c567e2da5fbc800b
2016-08-19 01:36:31 +00:00
Dmitriy Filchenko
de9e6fb4b0 Merge "Remove process_name.c" am: e5b7ad1c39
am: 97e3cb7074

Change-Id: I8ddeceadedd4ca689d96f3a854ba34f31d16683f
2016-08-19 01:33:31 +00:00
Dmitriy Filchenko
97e3cb7074 Merge "Remove process_name.c"
am: e5b7ad1c39

Change-Id: I8f98f5fe9ff526ed8780971eddef128ed46de271
2016-08-19 01:30:34 +00:00
Dmitriy Filchenko
1bb49f483b Remove process_name.c
BUG: 29824203

Change-Id: I88d67cafb8ec0c4eea3db047bac0671de698ba02
2016-08-18 23:54:46 +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