Skip to content

Commit 6d3f82c

Browse files
jBarzMylesBorins
authored andcommitted
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. [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]>
1 parent e54133b commit 6d3f82c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

deps/v8/src/api.cc

+24
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,12 @@ HandleScope::~HandleScope() {
789789
i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_);
790790
}
791791

792+
V8_NORETURN void* HandleScope::operator new(size_t) {
793+
base::OS::Abort();
794+
abort();
795+
}
796+
797+
void HandleScope::operator delete(void*, size_t) { base::OS::Abort(); }
792798

793799
int HandleScope::NumberOfHandles(Isolate* isolate) {
794800
return i::HandleScope::NumberOfHandles(
@@ -828,6 +834,12 @@ i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
828834
return escape_slot_;
829835
}
830836

837+
V8_NORETURN void* EscapableHandleScope::operator new(size_t) {
838+
base::OS::Abort();
839+
abort();
840+
}
841+
842+
void EscapableHandleScope::operator delete(void*, size_t) { base::OS::Abort(); }
831843

832844
SealHandleScope::SealHandleScope(Isolate* isolate) {
833845
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
@@ -849,6 +861,12 @@ SealHandleScope::~SealHandleScope() {
849861
current->sealed_level = prev_sealed_level_;
850862
}
851863

864+
V8_NORETURN void* SealHandleScope::operator new(size_t) {
865+
base::OS::Abort();
866+
abort();
867+
}
868+
869+
void SealHandleScope::operator delete(void*, size_t) { base::OS::Abort(); }
852870

853871
void Context::Enter() {
854872
i::Handle<i::Context> env = Utils::OpenHandle(this);
@@ -2273,6 +2291,12 @@ v8::TryCatch::~TryCatch() {
22732291
}
22742292
}
22752293

2294+
V8_NORETURN void* v8::TryCatch::operator new(size_t) {
2295+
base::OS::Abort();
2296+
abort();
2297+
}
2298+
2299+
void v8::TryCatch::operator delete(void*, size_t) { base::OS::Abort(); }
22762300

22772301
bool v8::TryCatch::HasCaught() const {
22782302
return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();

0 commit comments

Comments
 (0)