summaryrefslogtreecommitdiff
path: root/libutils/ProcessCallStack.cpp
diff options
context:
space:
mode:
authorDavid Pursell <dpursell@google.com>2016-09-23 09:19:12 -0700
committerDavid Pursell <dpursell@google.com>2016-09-23 13:56:40 -0700
commitd633cf0e8dcdea9539aa2ba312c0391a35b3b807 (patch)
tree91d5cc81bb719faaadf09d05e1ff12ee829d7ef9 /libutils/ProcessCallStack.cpp
parent58be4c19980ec347a809f5497697c42dd89a4b97 (diff)
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
Diffstat (limited to 'libutils/ProcessCallStack.cpp')
0 files changed, 0 insertions, 0 deletions