From c77a987b4d44e00329dd23a6c87de19b256fc4ef Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 5 Dec 2016 09:53:41 -0800 Subject: [PATCH] feat(util/thread): handle thread creation/join failure on Windows --- src/util/thread.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/thread.cpp b/src/util/thread.cpp index 0d8a20e59b..e96395eada 100644 --- a/src/util/thread.cpp +++ b/src/util/thread.cpp @@ -45,10 +45,15 @@ struct lthread::imp { m_proc(p) { m_thread = CreateThread(nullptr, m_thread_stack_size, _main, &m_proc, 0, nullptr); + if (m_thread == NULL) { + throw exception("failed to create thread"); + } } void join() { - WaitForSingleObject(m_thread, INFINITE); + if (WaitForSingleObject(m_thread, INFINITE) == WAIT_FAILED) { + throw exception("failed to join thread"); + } } }; #else