src: add debug CHECKs against empty handles

These checks were useful while investigating other issues;
using empty `Local<>`s can be very un-debuggable, because that
typically does not lead to assertions with debugging information
but rather crashes based on accessing invalid memory.

PR-URL: https://github.com/nodejs/node/pull/26125
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen authored and Rod Vagg committed 2019-02-28 23:35:32 +11:00
1 parent be671c3bf5
commit cbd3cf083a
2 files changed
+6

No files matched your search

+5
View File
@@ -139,6 +139,11 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
Local<Value> argv[],
async_context asyncContext) {
CHECK(!recv.IsEmpty());
#ifdef DEBUG
for (int i = 0; i < argc; i++)
CHECK(!argv[i].IsEmpty());
#endif
InternalCallbackScope scope(env, recv, asyncContext);
if (scope.Failed()) {
return MaybeLocal<Value>();
+1
View File
@@ -710,6 +710,7 @@ void DecorateErrorStack(Environment* env,
void FatalException(Isolate* isolate,
Local<Value> error,
Local<Message> message) {
CHECK(!error.IsEmpty());
HandleScope scope(isolate);
Environment* env = Environment::GetCurrent(isolate);