From e04a310cbaf02782fab6f62269eacd17911a72cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 10 May 2013 17:17:38 +0100 Subject: [PATCH] retrace: Join with runner threads before destroy runner objects. This fixes segfaults when exiting on windows. --- common/os_thread.hpp | 10 ++++++++++ retrace/retrace_main.cpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/common/os_thread.hpp b/common/os_thread.hpp index 51ac54f..f3ae210 100644 --- a/common/os_thread.hpp +++ b/common/os_thread.hpp @@ -374,6 +374,10 @@ namespace os { { } + inline + ~thread() { + } + template< class Function, class Arg > explicit thread( Function& f, Arg arg ) { #ifdef _WIN32 @@ -384,6 +388,12 @@ namespace os { #endif } + inline thread & + operator =(const thread &other) { + _native_handle = other._native_handle; + return *this; + } + inline bool joinable(void) const { return _native_handle != 0; diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp index 492deca..5e31c02 100644 --- a/retrace/retrace_main.cpp +++ b/retrace/retrace_main.cpp @@ -284,6 +284,12 @@ public: } } + ~RelayRunner() { + if (thread.joinable()) { + thread.join(); + } + } + /** * Thread main loop. */ -- 2.43.0