system_error::message() uses strerror for the generic and system categories. This function is not thread safe.
The fix is to use strerror_r. It has been available since 2001 for GNU libc and since BSD 4.4 on FreeBSD/OS X.
On platforms with GNU libc the extended version is used which always returns a valid string, even if an error occurs.
In single-threaded builds strerror is still used.