This is a story of an excursion to the bottom of a deep rabbit hole, where I discovered a foot gun in
libgcc. The investigation has cost me several days and I hope that by writing this up I can entertain others and save them the journey.
If a C++ application is compiled with GCC on Linux and statically linked against a non-GLibC C-library (like
libmusl), then there is a danger of a data race which leads to a busy loop happening after
main() and all static destructors have finished. The race happens, if the application does not use
pthread_cancel explicitly and if the very first exception which is thrown in the processes’ life is thrown in two different threads at the same time.