From 99c7f8ce9bb5afb0a9bb38287b7883e9d11b4a56 Mon Sep 17 00:00:00 2001 From: jBarz Date: Thu, 29 Dec 2016 16:53:34 -0500 Subject: [PATCH] deps: backport 224d376 from V8 upstream Orignial commit message: Abort in delete operators that shouldn't be called. Section 3.2 of the C++ standard states that destructor definitions implicitly "use" operator delete functions. Therefore, these operator delete functions must be defined even if they are never called by user code explicitly. http://www.open-std.org/JTC1/SC22/WG21/docs/ cwg_defects.html#261 gcc allows them to remain as empty definitions. However, not all compilers allow this. (e.g. xlc on zOS). This pull request creates definitions which if ever called, result in an abort. R=danno@chromium.org,jochen@chromium.org BUG= LOG=N Review-Url: https://codereview.chromium.org/2588433002 Cr-Commit-Position: refs/heads/master@{#41981} --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/api.cc | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 009a3b10425ee4..a39676e3779c60 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 4 #define V8_BUILD_NUMBER 500 -#define V8_PATCH_LEVEL 45 +#define V8_PATCH_LEVEL 46 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 6858a325c40a86..a4a0ed7c186546 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -875,6 +875,12 @@ HandleScope::~HandleScope() { i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); } +V8_NORETURN void* HandleScope::operator new(size_t) { + base::OS::Abort(); + abort(); +} + +void HandleScope::operator delete(void*, size_t) { base::OS::Abort(); } int HandleScope::NumberOfHandles(Isolate* isolate) { return i::HandleScope::NumberOfHandles( @@ -913,6 +919,13 @@ i::Object** EscapableHandleScope::Escape(i::Object** escape_value) { return escape_slot_; } +V8_NORETURN void* EscapableHandleScope::operator new(size_t) { + base::OS::Abort(); + abort(); +} + +void EscapableHandleScope::operator delete(void*, size_t) { base::OS::Abort(); } + SealHandleScope::SealHandleScope(Isolate* isolate) : isolate_(reinterpret_cast(isolate)) { i::HandleScopeData* current = isolate_->handle_scope_data(); @@ -931,6 +944,12 @@ SealHandleScope::~SealHandleScope() { current->sealed_level = prev_sealed_level_; } +V8_NORETURN void* SealHandleScope::operator new(size_t) { + base::OS::Abort(); + abort(); +} + +void SealHandleScope::operator delete(void*, size_t) { base::OS::Abort(); } void Context::Enter() { i::Handle env = Utils::OpenHandle(this); @@ -2315,6 +2334,12 @@ v8::TryCatch::~TryCatch() { } } +V8_NORETURN void* v8::TryCatch::operator new(size_t) { + base::OS::Abort(); + abort(); +} + +void v8::TryCatch::operator delete(void*, size_t) { base::OS::Abort(); } bool v8::TryCatch::HasCaught() const { return !reinterpret_cast(exception_)->IsTheHole(isolate_);