On Wed, 31 May 2023 at 21:15, J.W. Jagersma via Gcc-help <gcc-help@xxxxxxxxxxx> wrote: > > Hi all, > > In my cooperative scheduler I currently use a regular exception type for thread > cancellation. But these tend to get eaten, for example by std::iosteam > functions. > > Now I see those functions do catch and rethrow a __cxxabiv1::__forced_unwind > type, and I presume such an object can be thrown via _Unwind_ForcedUnwind(). > > But how do you actually use it? You don't. It exists for pthread_kill, not for users. > Specifically, how is the exception supposed to > be allocated, who is in charge of freeing it, The runtime does that as needed. > and how do you make sure it stops > where you want it to? You can't, it can never be stopped. If it is caught and not rethrown then the entire process is aborted. It must propagate to the initial function that was executed in the thread, and then when it leaves that function the thread is terminated.