From 22c826f5aa3811e758686fd00a8fe15728f6fc37 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 7 Jun 2018 14:43:45 +0200 Subject: src: do proper error checking in `AsyncWrap::MakeCallback` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At least one method on a native object is added as a getter, namely `MessagePort.prototype.onmessage`. When a MessagePort attempts to call this method from C++ in response to receiving data, it will first invoke that getter and then call the function. Since `worker.terminate()` interrupts execution, this means that the getter may fail (without being faulty code on its own). This means that at least one test exercising these methods in combination has been flaky and could have crashed, because we did not actually check that the getter returns a value so far, resulting in dereferencing an empty `Local`. The proper fix for this is to use the non-deprecated overload of `Get()` and check the result like we should be doing. Also, as a (related) fix, don’t crash if the method is not a function but rather something else, like a getter could provide. Example test failure: https://ci.nodejs.org/job/node-test-commit-linux-containered/4976/nodes=ubuntu1604_sharedlibs_zlib_x64/console 17:56:56 not ok 1955 parallel/test-worker-dns-terminate 17:56:56 --- 17:56:56 duration_ms: 1.237 17:56:56 severity: crashed 17:56:56 exitcode: -11 17:56:56 stack: |- PR-URL: https://github.com/nodejs/node/pull/21189 Reviewed-By: Anatoli Papirovski Reviewed-By: Benjamin Gruenbaum Reviewed-By: Joyee Cheung Reviewed-By: James M Snell --- src/node_messaging.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/node_messaging.h') diff --git a/src/node_messaging.h b/src/node_messaging.h index 9a13437d19..28122c526c 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -154,6 +154,8 @@ class MessagePort : public HandleWrap { std::unique_ptr Detach(); bool IsSiblingClosed() const; + void Close( + v8::Local close_callback = v8::Local()) override; size_t self_size() const override; -- cgit v1.2.3