From 277f43d2d0c4554d1c050a8c4e913cbf4d54cf4b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Sat, 25 Aug 2012 23:01:40 +0000 Subject: re PR libstdc++/54297 ([C++11] Segmentation fault with std::async and released shared state) PR libstdc++/54297 * include/std/future (~_Async_state_impl): Join thread before derived class members are destroyed. (~_Async_state_common): Only define non-trivial destructor when included from future.cc for ABI compatibility reasons. * src/c++11/future.cc (_GLIBCXX_ABI_COMPAT_ASYNC): Define. * testsuite/30_threads/async/54297.cc: New. From-SVN: r190672 --- libstdc++-v3/include/std/future | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3/include/std/future') diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index a8d7112..feae382 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -1427,10 +1427,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION class __future_base::_Async_state_common : public __future_base::_State_base { protected: -#ifdef _GLIBCXX_HAVE_TLS +#if defined(_GLIBCXX_HAVE_TLS) && defined(_GLIBCXX_ABI_COMPAT_ASYNC) ~_Async_state_common(); #else - ~_Async_state_common() { _M_join(); } + ~_Async_state_common() = default; #endif // Allow non-timed waiting functions to block until the thread completes, @@ -1457,6 +1457,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; } + ~_Async_state_impl() { _M_join(); } + private: typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; _Ptr_type _M_result; -- cgit v1.1