You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/07/24 20:17:03 UTC
[4/8] mesos git commit: Windows: Added `nullptr` checks when using
`libwinio_loop` pointer.
Windows: Added `nullptr` checks when using `libwinio_loop` pointer.
It was discovered that the `Socket` constructor could dereference a
null pointer (by way of `prepare_async()`) if the Windows IOCP event
loop had not yet been initialized. So now we check for its
initialization before each dereference, and return an error or fatal
log event.
In order to ensure that it is initialized in `test-linkee`, we call
`process::initialize()`. This should be fixed in the future, per
MESOS-9097.
Review: https://reviews.apache.org/r/67976
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/81597a03
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/81597a03
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/81597a03
Branch: refs/heads/master
Commit: 81597a0389db60f1d9143bf65c665cd1073339f1
Parents: 3e06a48
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Jul 18 14:49:56 2018 -0700
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Tue Jul 24 10:58:52 2018 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/tests/test_linkee.cpp | 4 ++++
3rdparty/libprocess/src/windows/event_loop.cpp | 25 +++++++++++++++++++--
3rdparty/libprocess/src/windows/io.cpp | 5 +++++
3 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/81597a03/3rdparty/libprocess/src/tests/test_linkee.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/test_linkee.cpp b/3rdparty/libprocess/src/tests/test_linkee.cpp
index cc48271..0ba54ea 100644
--- a/3rdparty/libprocess/src/tests/test_linkee.cpp
+++ b/3rdparty/libprocess/src/tests/test_linkee.cpp
@@ -99,6 +99,10 @@ int main(int argc, char** argv)
EXIT(EXIT_FAILURE) << "Usage: test-linkee <UPID>";
}
+ // NOTE: On Windows, this initialization must take place before creating a
+ // `Socket`, otherwise the IOCP handle will be uninitialized. See MESOS-9097.
+ process::initialize();
+
// Create a server socket.
Try<Socket> create = Socket::create();
if (create.isError()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/81597a03/3rdparty/libprocess/src/windows/event_loop.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/windows/event_loop.cpp b/3rdparty/libprocess/src/windows/event_loop.cpp
index 0050ff0..33fbf36 100644
--- a/3rdparty/libprocess/src/windows/event_loop.cpp
+++ b/3rdparty/libprocess/src/windows/event_loop.cpp
@@ -48,6 +48,11 @@ void EventLoop::initialize()
void EventLoop::delay(
const Duration& duration, const std::function<void()>& function)
{
+ if (!libwinio_loop) {
+ // TODO(andschwa): Remove this check, see MESOS-9097.
+ LOG(FATAL) << "Windows IOCP event loop is not initialized";
+ }
+
libwinio_loop->launchTimer(duration, function);
}
@@ -60,9 +65,25 @@ double EventLoop::time()
}
-void EventLoop::run() { libwinio_loop->run(); }
+void EventLoop::run()
+{
+ if (!libwinio_loop) {
+ // TODO(andschwa): Remove this check, see MESOS-9097.
+ LOG(FATAL) << "Windows IOCP event loop is not initialized";
+ }
+
+ libwinio_loop->run();
+}
+
+void EventLoop::stop()
+{
+ if (!libwinio_loop) {
+ // TODO(andschwa): Remove this check, see MESOS-9097.
+ LOG(FATAL) << "Windows IOCP event loop is not initialized";
+ }
-void EventLoop::stop() { libwinio_loop->stop(); }
+ libwinio_loop->stop();
+}
} // namespace process {
http://git-wip-us.apache.org/repos/asf/mesos/blob/81597a03/3rdparty/libprocess/src/windows/io.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/windows/io.cpp b/3rdparty/libprocess/src/windows/io.cpp
index 1f9adde..90e780d 100644
--- a/3rdparty/libprocess/src/windows/io.cpp
+++ b/3rdparty/libprocess/src/windows/io.cpp
@@ -79,6 +79,11 @@ Future<size_t> write(int_fd fd, const void* data, size_t size)
Try<Nothing> prepare_async(int_fd fd)
{
if (fd.is_overlapped()) {
+ // TODO(andschwa): Remove this check, see MESOS-9097.
+ if (!libwinio_loop) {
+ return Error("Windows IOCP event loop is not initialized");
+ }
+
return libwinio_loop->registerHandle(fd);
}