Skip to content

Commit

Permalink
deps: backport 224d376 from V8 upstream
Browse files Browse the repository at this point in the history
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.

  [email protected],[email protected]
  BUG=
  LOG=N

  Review-Url: https://codereview.chromium.org/2588433002
  Cr-Commit-Position: refs/heads/master@{#41981}

PR-URL: #10546
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
jBarz authored and MylesBorins committed Jan 31, 2017
1 parent a2f0285 commit 5c5f5fb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,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(
Expand Down Expand Up @@ -828,6 +834,12 @@ 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) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
Expand All @@ -849,6 +861,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<i::Context> env = Utils::OpenHandle(this);
Expand Down Expand Up @@ -2273,6 +2291,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<i::Object*>(exception_)->IsTheHole();
Expand Down

0 comments on commit 5c5f5fb

Please sign in to comment.