diff --git a/src/messages.cc b/src/messages.cc index 9489071403..5f89860b2f 100644 --- a/src/messages.cc +++ b/src/messages.cc @@ -144,10 +144,13 @@ base::SmartArrayPointer MessageHandler::GetLocalizedMessage( CallSite::CallSite(Isolate* isolate, Handle call_site_obj) : isolate_(isolate) { + Handle maybe_function = JSObject::GetDataProperty( + call_site_obj, isolate->factory()->call_site_function_symbol()); + if (!maybe_function->IsJSFunction()) return; + + fun_ = Handle::cast(maybe_function); receiver_ = JSObject::GetDataProperty( call_site_obj, isolate->factory()->call_site_receiver_symbol()); - fun_ = Handle::cast(JSObject::GetDataProperty( - call_site_obj, isolate->factory()->call_site_function_symbol())); pos_ = Handle::cast(JSObject::GetDataProperty( call_site_obj, isolate->factory()->call_site_position_symbol())) diff --git a/src/messages.h b/src/messages.h index 0282c6fb7d..a47bf57d45 100644 --- a/src/messages.h +++ b/src/messages.h @@ -62,6 +62,8 @@ class CallSite { bool IsEval(); bool IsConstructor(); + bool IsValid() { return !fun_.is_null(); } + private: Isolate* isolate_; Handle receiver_; diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc index 90d5532af3..fdf3961a5f 100644 --- a/src/runtime/runtime-internal.cc +++ b/src/runtime/runtime-internal.cc @@ -318,6 +318,7 @@ RUNTIME_FUNCTION(Runtime_FormatMessageString) { CONVERT_ARG_HANDLE_CHECKED(JSObject, call_site_obj, 0); \ Handle result; \ CallSite call_site(isolate, call_site_obj); \ + RUNTIME_ASSERT(call_site.IsValid()) \ return RETURN(call_site.NAME(), isolate); \ } diff --git a/test/mjsunit/regress-crbug-528379.js b/test/mjsunit/regress-crbug-528379.js new file mode 100644 index 0000000000..f335f6a104 --- /dev/null +++ b/test/mjsunit/regress-crbug-528379.js @@ -0,0 +1,8 @@ +// Copyright 2015 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. + +// Flags: --enable-slow-asserts + +Error.prepareStackTrace = function(e, frames) { return frames; } +assertThrows(function() { new Error().stack[0].getMethodName.call({}); });