Commit 224d3764 authored by jbarboza's avatar jbarboza Committed by Commit bot

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}
parent 734a7615
......@@ -867,8 +867,8 @@ class V8_EXPORT HandleScope {
HandleScope(const HandleScope&) = delete;
void operator=(const HandleScope&) = delete;
void* operator new(size_t size) = delete;
void operator delete(void*, size_t) = delete;
void* operator new(size_t size);
void operator delete(void*, size_t);
protected:
V8_INLINE HandleScope() {}
......@@ -919,8 +919,8 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
EscapableHandleScope(const EscapableHandleScope&) = delete;
void operator=(const EscapableHandleScope&) = delete;
void* operator new(size_t size) = delete;
void operator delete(void*, size_t) = delete;
void* operator new(size_t size);
void operator delete(void*, size_t);
private:
internal::Object** Escape(internal::Object** escape_value);
......@@ -934,8 +934,8 @@ class V8_EXPORT SealHandleScope {
SealHandleScope(const SealHandleScope&) = delete;
void operator=(const SealHandleScope&) = delete;
void* operator new(size_t size) = delete;
void operator delete(void*, size_t) = delete;
void* operator new(size_t size);
void operator delete(void*, size_t);
private:
internal::Isolate* const isolate_;
......@@ -7892,8 +7892,8 @@ class V8_EXPORT TryCatch {
TryCatch(const TryCatch&) = delete;
void operator=(const TryCatch&) = delete;
void* operator new(size_t size) = delete;
void operator delete(void*, size_t) = delete;
void* operator new(size_t size);
void operator delete(void*, size_t);
private:
void ResetInternal();
......
......@@ -978,6 +978,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(
......@@ -1016,6 +1022,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<i::Isolate*>(isolate)) {
i::HandleScopeData* current = isolate_->handle_scope_data();
......@@ -1034,6 +1047,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);
......@@ -2514,6 +2533,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(isolate_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment