On Wed, 8 Dec 2021 at 00:36, Jonathan Wakely wrote: > > On Tue, 7 Dec 2021 at 21:52, Florian Weimer wrote: > > > > * Jonathan Wakely: > > > > > On Tue, 7 Dec 2021, 21:20 Florian Weimer via Libstdc++, > > > wrote: > > > > > > * Jonathan Wakely via Libstdc: > > > > > > > If necessary we could keep the terminate-on-cancellation behaviour as > > > > _ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE@GLIBCXX_3.4.11 > > > > and export the new behaviour as @@GLIBCXX_3.4.30, although this patch > > > > doesn't do that. > > > > > > Note that if this fix escapes into the wild and then you have to make > > > the symbol version change, you will break newer applications. In a few > > > cases in glibc, we proactively added aliases at a different symbol > > > version, but with the same implementation (at first). > > > > > > To be safe, we probably should preserve the old behaviour for the old > > > version of the symbol. If we decide that the new behaviour is always > > > preferable, we could change that later by making the old symbol an > > > alias for the new. If we don't decide that, we'll be glad we made it a > > > separate symbol. > > > > On the other hand, with separate versions, it's possible to reintroduce > > the old behavior at a later date, as a bugfix. It's not strictly > > necessary to do that work upfront. It's just nice to have this option. > > Ah yes, a new symbol version gives us more flexibility in every direction. > > > > I'll see if I can get it working with two versioned symbols. We don't > > > actually do that in libstdc++ currently, we only have a single version > > > of every symbol. > > > > Ping me if you want to discuss options. 8-> > > Thanks. I'll try it and let you know how I get on. After resolving a PEBKAC issue, here's an incremental diff that preserves the old behaviour for the existing @GLIBCXX_3.4.11 symbol, but adds a new @@GLIBCXX_3.4.30 symbol that supports cancellation via __forced_unwind. Maybe we should also do this in the implementation of the old noexcept function: __attribute__((used)) void __nothrow_wait_cv::wait(std::unique_lock& lock) noexcept { int old; int err = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old); this->condition_variable::wait(lock); if (!err && old != PTHREAD_CANCEL_DISABLE) pthread_setcancelstate(old, &old); } This would prevent cancellation from terminating a process if it uses the old symbol. So we'd have a new symbol that supports cancellation, and an old one that safely disables it.