The manage_exception_state try to save and restore the exception state from/to the current thread that executing the fiber, but only one __cxa_get_globals() call is generated for the outer function after optimization, which would be incorrect if fiber resume on another thread.
|
class manage_exception_state { |
|
public: |
|
manage_exception_state() { |
|
exception_state_ = *__cxa_get_globals(); |
|
} |
|
~manage_exception_state() { |
|
*__cxa_get_globals() = exception_state_; |
|
} |
|
private: |
|
__cxa_eh_globals exception_state_; |
|
}; |
Result from compiler explorer
// check disassembly of this function
void foo(boost::context::fiber&& f) { std::move(f).resume(); }