On 22/09/16 12:15 +0100, Jonathan Wakely wrote: >On 22/09/16 11:16 +0100, Jonathan Wakely wrote: >>(Somebody should fix PR58938 so exception_ptr is portable). > >Christophe, would you be able to test this patch? > >It uses a single global mutex for exception_ptr objects, which doesn't >scale well but that probably isn't a problem for processors without >lock-free atomics for single words. > >This also solves the problem of mismatched -march options, where the >header is compiled for a CPU that supports the atomics but >libstdc++.so was built for an older CPU that doesn't support them, and >linking fails (as in https://gcc.gnu.org/PR58938#c13). We'd also need something like this extra piece, to ensure we don't leak exceptions. Currently __gxx_exception_cleanup assumes that if ATOMIC_INT_LOCK_FREE < 2 the referenceCount can never be greater than 1, because there are not exception_ptr objects that could increase it. If we enable exception_ptr unconditionally then that assumption doesn't hold. This patch uses the exception_ptr code to do the cleanup, under the same mutex as any other increments and decrements of the reference count. It's a bit of a hack though.