Skip to content

Commit

Permalink
[builtins] abort FrameFunctionIterator::next if frame summary empty
Browse files Browse the repository at this point in the history
Previously, FrameFunctionIterator::next() assumed that the frame summary
was non-empty. It's now possible for the list not to be empty, if the
JS microtask pump invokes a builtin function which uses
FrameFunctionIterator directly. While this is unlikely to show up in
real world code, it is necessary to handle it to prevent crashes.

BUG=chromium:794744
R=mstarzinger@chromium.org, cbruni@chromium.org, verwaest@chromium.org

Change-Id: Ie95c2228544f57730d1c6c1ff955b2c94ff1c06b
Reviewed-on: https://chromium-review.googlesource.com/833266
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#50221}
  • Loading branch information
caitp authored and Commit Bot committed Dec 20, 2017
1 parent 17a6ec1 commit 18dc491
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/accessors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -952,16 +952,17 @@ class FrameFunctionIterator {
private:
MaybeHandle<JSFunction> next() {
while (true) {
inlined_frame_index_--;
if (inlined_frame_index_ == -1) {
if (inlined_frame_index_ <= 0) {
if (!frame_iterator_.done()) {
frame_iterator_.Advance();
frames_.clear();
inlined_frame_index_ = -1;
GetFrames();
}
if (inlined_frame_index_ == -1) return MaybeHandle<JSFunction>();
inlined_frame_index_--;
}

--inlined_frame_index_;
Handle<JSFunction> next_function =
frames_[inlined_frame_index_].AsJavaScript().function();
// Skip functions from other origins.
Expand Down
8 changes: 8 additions & 0 deletions test/mjsunit/es8/regress/regress-794744.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Object.getOwnPropertyDescriptors loads %FunctionPrototype%.caller, an
// accessor property which inspects the current callstack. Verify that this
// callstack iteration doesn't crash when there are no JS frames on the stack.
Promise.resolve(function () {}).then(Object.getOwnPropertyDescriptors);

0 comments on commit 18dc491

Please sign in to comment.