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:
parent
586318aa9f
commit
783c65ebc4
@ -139,6 +139,11 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
|
|||||||
Local<Value> argv[],
|
Local<Value> argv[],
|
||||||
async_context asyncContext) {
|
async_context asyncContext) {
|
||||||
CHECK(!recv.IsEmpty());
|
CHECK(!recv.IsEmpty());
|
||||||
|
#ifdef DEBUG
|
||||||
|
for (int i = 0; i < argc; i++)
|
||||||
|
CHECK(!argv[i].IsEmpty());
|
||||||
|
#endif
|
||||||
|
|
||||||
InternalCallbackScope scope(env, recv, asyncContext);
|
InternalCallbackScope scope(env, recv, asyncContext);
|
||||||
if (scope.Failed()) {
|
if (scope.Failed()) {
|
||||||
return MaybeLocal<Value>();
|
return MaybeLocal<Value>();
|
||||||
|
@ -710,6 +710,7 @@ void DecorateErrorStack(Environment* env,
|
|||||||
void FatalException(Isolate* isolate,
|
void FatalException(Isolate* isolate,
|
||||||
Local<Value> error,
|
Local<Value> error,
|
||||||
Local<Message> message) {
|
Local<Message> message) {
|
||||||
|
CHECK(!error.IsEmpty());
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
|
|
||||||
Environment* env = Environment::GetCurrent(isolate);
|
Environment* env = Environment::GetCurrent(isolate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user