Skip to content

Commit

Permalink
src: add debug CHECKs against empty handles
Browse files Browse the repository at this point in the history
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 <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax committed Feb 17, 2019
1 parent 586318a commit 783c65e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api/callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
Expand Down
1 change: 1 addition & 0 deletions src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 783c65e

Please sign in to comment.