On illumos-based distributions whose GCC is built with the --enable-clocale=dragonfly option (e.g. OmniOS, OpenIndiana), the std::ctype<char>::~ctype() destructor passes an uninitialized value to freelocale().
Constructing and destroying std::locale("") in SetupEnvironment() therefore intermittently crashes, e.g. with "libc thread failure: lfree() called with a misaligned pointer".
Upstream reports:
- https://github.com/illumos/gcc/pull/56#issuecomment-5933176361
- https://github.com/omniosorg/omnios-build/issues/4253
- https://www.illumos.org/issues/18481
Closes https://github.com/hebasto/bitcoin-core-nightly/issues/315.