Commit ca1dcc9c authored by alph's avatar alph Committed by Commit bot

Fix MSAN error on arm64 bot.

The main fix is to mark stack memory the SafeStackFrameIterator
accesses as initialied.

Drive-by: Make sure we bail out when the simulator is in the
process of updating FP/SP registers.

BUG=v8:5156

Review-Url: https://codereview.chromium.org/2104763002
Cr-Commit-Position: refs/heads/master@{#37315}
parent 2f0cb3af
......@@ -7550,7 +7550,12 @@ void Isolate::GetStackSample(const RegisterState& state, void** frames,
regs.pc = state.pc;
regs.sp = state.sp;
regs.fp = state.fp;
i::SimulatorHelper::FillRegisters(isolate, &regs);
if (!i::SimulatorHelper::FillRegisters(isolate, &regs)) {
sample_info->frames_count = 0;
sample_info->vm_state = OTHER;
sample_info->external_callback_entry = nullptr;
return;
}
#else
const RegisterState& regs = state;
#endif
......
......@@ -304,7 +304,8 @@ bool SafeStackFrameIterator::IsValidExitFrame(Address fp) const {
if (!IsValidStackAddress(sp)) return false;
StackFrame::State state;
ExitFrame::FillState(fp, sp, &state);
return *state.pc_address != NULL;
MSAN_MEMORY_IS_INITIALIZED(state.pc_address, sizeof(state.pc_address));
return *state.pc_address != nullptr;
}
......@@ -414,11 +415,9 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
State* state) {
DCHECK(state->fp != NULL);
#if defined(USE_SIMULATOR)
MSAN_MEMORY_IS_INITIALIZED(
state->fp + CommonFrameConstants::kContextOrFrameTypeOffset,
kPointerSize);
#endif
Object* marker = Memory::Object_at(
state->fp + CommonFrameConstants::kContextOrFrameTypeOffset);
if (!iterator->can_access_heap_objects_) {
......@@ -427,10 +426,8 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
// the VM with a signal at any arbitrary instruction, with essentially
// anything on the stack. So basically none of these checks are 100%
// reliable.
#if defined(USE_SIMULATOR)
MSAN_MEMORY_IS_INITIALIZED(
state->fp + StandardFrameConstants::kFunctionOffset, kPointerSize);
#endif
Object* maybe_function =
Memory::Object_at(state->fp + StandardFrameConstants::kFunctionOffset);
if (!marker->IsSmi()) {
......@@ -607,9 +604,7 @@ StackFrame::Type ExitFrame::GetStateForFramePointer(Address fp, State* state) {
}
Address ExitFrame::ComputeStackPointer(Address fp) {
#if defined(USE_SIMULATOR)
MSAN_MEMORY_IS_INITIALIZED(fp + ExitFrameConstants::kSPOffset, kPointerSize);
#endif
return Memory::Address_at(fp + ExitFrameConstants::kSPOffset);
}
......
......@@ -647,8 +647,9 @@ class Ticker: public sampler::Sampler {
v8::Isolate* v8_isolate = isolate();
Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
#if defined(USE_SIMULATOR)
SimulatorHelper::FillRegisters(isolate,
const_cast<v8::RegisterState*>(&state));
if (!SimulatorHelper::FillRegisters(isolate,
const_cast<v8::RegisterState*>(&state)))
return;
#endif
TickSample* sample = isolate->cpu_profiler()->StartTickSample();
TickSample sample_obj;
......
......@@ -125,7 +125,8 @@ bool TickSample::GetStackSample(Isolate* isolate, const v8::RegisterState& regs,
if (sample_info->vm_state == GC) return true;
Address js_entry_sp = isolate->js_entry_sp();
if (js_entry_sp == 0) return true; // Not executing JS now.
if (js_entry_sp == nullptr) return true; // Not executing JS now.
DCHECK(regs.sp);
if (regs.pc && IsNoFrameRegion(static_cast<Address>(regs.pc))) {
// Can't collect stack.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment