Fix possibly-unaligned read in TickSample::Init

This is a speculative fix for issue 8744. I couldn't get it to
repro locally, but the stracktrace from the failing bot run points
at TickSample::Init, and according to code comments in that function
the value of {regs.sp} can be "arbitrary", so we must read from
that address using a method that's robust towards unalignment.

Bug: v8:8744
Change-Id: I7a45cc257e0eb557715ec67d9e66e54a6f2c1867
Reviewed-on: https://chromium-review.googlesource.com/c/1440463
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59186}
This commit is contained in:
Jakob Kummerow 2019-01-28 12:23:01 -08:00 committed by Commit Bot
parent f5ba52e234
commit a8268e6b3c

View File

@ -173,8 +173,7 @@ DISABLE_ASAN void TickSample::Init(Isolate* v8_isolate,
MSAN_MEMORY_IS_INITIALIZED(regs.sp, sizeof(void*));
// Sample potential return address value for frameless invocation of
// stubs (we'll figure out later, if this value makes sense).
tos = reinterpret_cast<void*>(
i::Memory<i::Address>(reinterpret_cast<i::Address>(regs.sp)));
tos = i::ReadUnalignedValue<void*>(reinterpret_cast<i::Address>(regs.sp));
} else {
tos = nullptr;
}