-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is resumable task exception safe? #1293
Comments
I believe save/restore cxa global states is managed as part of the C++ runtime support for exception handling. In the case of TBB, exception handling is facilitated through functions available in stdexcept/exception header. Nevertheless for any parallel algorithm with resumable task any exceptions that arise are captured and subsequently thrown on the thread that initiated the algorithm. |
libc++/libstdc++ based exception handling typically uses per thread cxa globals. When you switch the context, these gobals may be mismatched. On win/msvc, structured exception handling is stack based, so win fiber is also exception safe. A portable way to handle cxa global is to overwrite Without switching those globals, simple throw and catch are just fine, but when you try switching the context in the middle of stack unwinding (for doing some async cleanup maybe), crashes may happen. Popular implementation like boost.context doesn't do this, because it wants a portable way to control the stack space, while win fiber won't let you do this, and cxa globals only work in libc++/libstdc++. So such implementation would forbid switching context while unwinding. |
Thank you for providing more information! We were previously unaware that libc++/libstdc++ based exception handling relies on per thread cxa global. We will investigate further and provide necessary patch to support exception safety in resumable task. |
Would you be able to provide us a reproducer which cause the issue with TBB suspend/resume API? |
I am assuming this has been resolved. Please provide a reproducer and feel free to reopen the issue if you think we could implement exception safety in a better way. |
I know windows fiber is exception safe with proper compiler flags. But gcc/llvm based implementations typically require save/restore cxa global states while switching context to assure correct exception behaviour, which I didn't find in the source.
The text was updated successfully, but these errors were encountered: