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

Fix possible crash in SafeStackFrameIterator

Safe stack iterator is supposed to work even when the stack is in an inconsistent state.
E.g. during cpu profile sample recording. This patch eliminates a crash if the frame marker
is found to be bogus.

BUG=v8:4705
LOG=N

Review URL: https://codereview.chromium.org/1633323002

Cr-Commit-Position: refs/heads/master@{#33558}
parent fd20f165
......@@ -121,15 +121,15 @@ StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type,
StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type) {
#define FRAME_TYPE_CASE(type, field) \
case StackFrame::type: result = &field##_; break;
case StackFrame::type: \
return &field##_;
StackFrame* result = NULL;
switch (type) {
case StackFrame::NONE: return NULL;
STACK_FRAME_TYPE_LIST(FRAME_TYPE_CASE)
default: break;
}
return result;
return NULL;
#undef FRAME_TYPE_CASE
}
......@@ -234,7 +234,7 @@ SafeStackFrameIterator::SafeStackFrameIterator(
}
if (SingletonFor(type) == NULL) return;
frame_ = SingletonFor(type, &state);
if (frame_ == NULL) return;
DCHECK(frame_);
Advance();
......@@ -272,8 +272,12 @@ void SafeStackFrameIterator::AdvanceOneFrame() {
// Advance to the previous frame.
StackFrame::State state;
StackFrame::Type type = frame_->GetCallerState(&state);
if (SingletonFor(type) == NULL) {
frame_ = NULL;
return;
}
frame_ = SingletonFor(type, &state);
if (frame_ == NULL) return;
DCHECK(frame_);
// Check that we have actually moved to the previous frame in the stack.
if (frame_->sp() < last_sp || frame_->fp() < last_fp) {
......
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