From da3fa4f6a934cb1cf7a89bf0589c8de4431cf925 Mon Sep 17 00:00:00 2001 From: zhykzhykzhyk Date: Mon, 5 Jan 2026 01:13:10 +0800 Subject: [PATCH 1/2] Ensure manage_exception_state uses correct TLS Solves #323 --- include/boost/context/fiber_fcontext.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/context/fiber_fcontext.hpp b/include/boost/context/fiber_fcontext.hpp index 2c91b110..543ba6cf 100644 --- a/include/boost/context/fiber_fcontext.hpp +++ b/include/boost/context/fiber_fcontext.hpp @@ -87,10 +87,10 @@ struct __cxa_eh_globals { class manage_exception_state { public: - manage_exception_state() { + BOOST_NOINLINE manage_exception_state() { exception_state_ = *__cxa_get_globals(); } - ~manage_exception_state() { + BOOST_NOINLINE ~manage_exception_state() { *__cxa_get_globals() = exception_state_; } private: From 781a15e4368ada7c2ac1464ceb8816e23f89dc12 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Mon, 23 Feb 2026 07:51:30 +0100 Subject: [PATCH 2/2] Fix exception state handling in manage_exception_state --- include/boost/context/fiber_fcontext.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/context/fiber_fcontext.hpp b/include/boost/context/fiber_fcontext.hpp index 543ba6cf..67717edf 100644 --- a/include/boost/context/fiber_fcontext.hpp +++ b/include/boost/context/fiber_fcontext.hpp @@ -88,10 +88,10 @@ struct __cxa_eh_globals { class manage_exception_state { public: BOOST_NOINLINE manage_exception_state() { - exception_state_ = *__cxa_get_globals(); + exception_state_ = *(volatile __cxa_eh_globals *)__cxa_get_globals(); } BOOST_NOINLINE ~manage_exception_state() { - *__cxa_get_globals() = exception_state_; + *(volatile __cxa_eh_globals *)__cxa_get_globals() = exception_state_; } private: __cxa_eh_globals exception_state_;