Commit 6f8b501c authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

cppgc: Informative message in case of delete

Outside of unittests, if someone tried to delete a GCed object manually
they would get a silent crash without a stacktrace or any error
messages. This CL replaces the silent crash with an informative message.

Change-Id: Ied8895dab43ce7e3a9bf778b13e77d377d269fce
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3468346
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79141}
parent 35fefc59
...@@ -62,7 +62,8 @@ class GarbageCollected { ...@@ -62,7 +62,8 @@ class GarbageCollected {
// virtual destructor requires an unambiguous, accessible 'operator delete'. // virtual destructor requires an unambiguous, accessible 'operator delete'.
void operator delete(void*) { void operator delete(void*) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
internal::Abort(); internal::Fatal(
"Manually deleting a garbage collected object is not allowed");
#endif // V8_ENABLE_CHECKS #endif // V8_ENABLE_CHECKS
} }
void operator delete[](void*) = delete; void operator delete[](void*) = delete;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "cppgc/source-location.h"
#include "v8-platform.h" // NOLINT(build/include_directory) #include "v8-platform.h" // NOLINT(build/include_directory)
#include "v8config.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory)
...@@ -145,7 +146,8 @@ V8_EXPORT void ShutdownProcess(); ...@@ -145,7 +146,8 @@ V8_EXPORT void ShutdownProcess();
namespace internal { namespace internal {
V8_EXPORT void Abort(); V8_EXPORT void Fatal(const std::string& reason = std::string(),
const SourceLocation& = SourceLocation::Current());
} // namespace internal } // namespace internal
......
...@@ -16,7 +16,13 @@ ...@@ -16,7 +16,13 @@
namespace cppgc { namespace cppgc {
namespace internal { namespace internal {
void Abort() { v8::base::OS::Abort(); } void Fatal(const std::string& reason, const SourceLocation& loc) {
#ifdef DEBUG
V8_Fatal(loc.FileName(), static_cast<int>(loc.Line()), "%s", reason.c_str());
#else // !DEBUG
V8_Fatal("%s", reason.c_str());
#endif // !DEBUG
}
void FatalOutOfMemoryHandler::operator()(const std::string& reason, void FatalOutOfMemoryHandler::operator()(const std::string& reason,
const SourceLocation& loc) const { const SourceLocation& loc) const {
......
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