From 64c518d06d6a947c466e0948980054308f33cd66 Mon Sep 17 00:00:00 2001 From: jgruber Date: Fri, 2 Sep 2016 02:51:04 -0700 Subject: [PATCH] Do not include Error.captureStackTrace in the trace BUG=v8:5342 Review-Url: https://codereview.chromium.org/2307783002 Cr-Commit-Position: refs/heads/master@{#39124} --- src/builtins/builtins-error.cc | 2 +- src/isolate.cc | 9 --------- test/mjsunit/regress/regress-5342.js | 7 +++++++ 3 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 test/mjsunit/regress/regress-5342.js diff --git a/src/builtins/builtins-error.cc b/src/builtins/builtins-error.cc index c9150b8515..c2a7b99035 100644 --- a/src/builtins/builtins-error.cc +++ b/src/builtins/builtins-error.cc @@ -44,7 +44,7 @@ BUILTIN(ErrorCaptureStackTrace) { } Handle object = Handle::cast(object_obj); Handle caller = args.atOrUndefined(isolate, 2); - FrameSkipMode mode = caller->IsJSFunction() ? SKIP_UNTIL_SEEN : SKIP_NONE; + FrameSkipMode mode = caller->IsJSFunction() ? SKIP_UNTIL_SEEN : SKIP_FIRST; // Collect the stack trace. diff --git a/src/isolate.cc b/src/isolate.cc index 722fc58a32..545c0dde3d 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -324,17 +324,8 @@ class StackTraceHelper { mode_(mode), caller_(caller), skip_next_frame_(true) { - // The caller parameter can be used to skip a specific set of frames in the - // stack trace. It can be: - // * null, when called from a standard error constructor. We unconditionally - // skip the top frame, which is always a builtin-exit frame for the error - // constructor builtin. - // * a JSFunction, when called by the user from Error.captureStackTrace(). - // We skip each frame until encountering the caller function. - // * For any other value, all frames are included in the trace. switch (mode_) { case SKIP_FIRST: - DCHECK(caller_.is_null()); skip_next_frame_ = true; break; case SKIP_UNTIL_SEEN: diff --git a/test/mjsunit/regress/regress-5342.js b/test/mjsunit/regress/regress-5342.js new file mode 100644 index 0000000000..8cdd808622 --- /dev/null +++ b/test/mjsunit/regress/regress-5342.js @@ -0,0 +1,7 @@ +// Copyright 2016 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. + +var o = {} +Error.captureStackTrace(o); +assertEquals(-1, o.stack.indexOf("captureStackTrace"));