Like libstdc++, we're checking in some places for abi::__forced_unwind
, and just re-throw it instead of taking some other action. Like libstdc++, we catch it by reference:
try {
/* ... */
} catch (abi::__forced_unwind&) {
throw;
} catch (...) {
/* ... */
}
But if we actually pthread_cancel to exercise the code, ubsan complains:
runtime error: reference binding to null pointer of type 'struct __forced_unwind'
Here, it doesn't matter whether we catch by const-ref or mutable ref.
Are we (and libstdc++) actually running into UB here, or is it a False Positive in GCC's UBSan implementation?