Skip to content

Commit cbd3cf0

Browse files
addaleaxrvagg
authored andcommitted
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: #26125 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent be671c3 commit cbd3cf0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/api/callback.cc

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
139139
Local<Value> argv[],
140140
async_context asyncContext) {
141141
CHECK(!recv.IsEmpty());
142+
#ifdef DEBUG
143+
for (int i = 0; i < argc; i++)
144+
CHECK(!argv[i].IsEmpty());
145+
#endif
146+
142147
InternalCallbackScope scope(env, recv, asyncContext);
143148
if (scope.Failed()) {
144149
return MaybeLocal<Value>();

src/node_errors.cc

+1
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ void DecorateErrorStack(Environment* env,
710710
void FatalException(Isolate* isolate,
711711
Local<Value> error,
712712
Local<Message> message) {
713+
CHECK(!error.IsEmpty());
713714
HandleScope scope(isolate);
714715

715716
Environment* env = Environment::GetCurrent(isolate);

0 commit comments

Comments
 (0)