From: Keith M. <kei...@us...> - 2016-12-04 21:18:19
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/12/16 17:02, DAVENPORT, MARC wrote: > I found a couple relevant pages on the web. The first discusses the > thread safety of strerror and proposes a short unit test that quickly > fails: > > http://lua-users.org/lists/lua-l/2012-03/msg00691.html Thanks. Do you mean quickly fails for you, when you compile and link it with my tentative strerror_r() implementation? Or just that the OP (on the Lua list) suggested that it quickly failed on his OS-X box? FWIW, I modified it to use win32threads, (instead of pthreads), and it does *not* fail for me, (even after several hundred million iterations within six concurrent threads). Frankly, given MSDN's documented use of _sys_nerr and _sys_errlist, and assuming an implementation based on the obvious relationship between strerror() and these two, I can see no mechanism whereby strerror() itself could be anything other than thread safe, provided the content of _sys_errlist remains unchanged, (even if a single instance is shared by multiple threads). Why might _sys_errlist change? Perhaps as a result of a locale change, (but the proposed test case doesn't perform one). However, even if I include a setlocale() call, requesting a switch to (say) French, or German, I get nothing but English messages, returned by strerror() on my WinXP VM, (maybe a quirk of my primarily English language installation -- even if I set an alternative language via control panel, the entire UI remains resolutely in English), and the test continues to run indefinitely, without failure. Looks to me as if my tentative strerror_r() implementation should be fit for purpose, unless someone can devise a more rigorous test to prove otherwise. - -- Regards, Keith. Public key available from keys.gnupg.net Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQIcBAEBAgAGBQJYRIgTAAoJEMCtNsY0flo/k84P/AsO1BuT2UzbwI6aUySqRghX o/fdryAg/1zixrIzP7v/+wSsvhUBiG48IqbYwQn7wfI4mJ/mq6WjZfHnqtzXLzdF Dd1WReXbmsIKwbU3nlVLmjNCIvESM9fX0XM5ElU+sHCQqXS4bTMKiNZj49sStFh7 n39y8BFy/hepmPtCIzzB9rtQtdLOy0VCqqKfPuUjKagBW8q1xQbyat9ZeGA9Dhn7 Wgpv18ERH0cGhhDH/rjjp9l3FAKzbtUXP4LU3fykcCDD2eFpzVpHjYXkaVYL12r+ d3MQWZtWxhU8mSn91ehgra+hYZLU/BxTyoSdZ4jgW1EtnqEfLqJdqqtC6eEnrjNc 0Z+K58Arerf8KhUSQzPQ2dk3kx75yCYB//O8JUyyQsnsERXa+t0GRg10nBiAlQsb xaFqk+HR1FvI+YNt7UkTuhoXk8DrGOUhYQXXvK68VzwFhVY0EGmRGODazBND4cq1 fKtn8A0B/UJsi5W5FMWhmhjmEcqP0J8yeBOoFGprsIFuYUF5kCran8cz59sEK+Me lUfAxHEC7tosOnYowkSSdO7vJVShiJ12yli/1XN2pjCMMrMiON2N0+2LwNsXwDtM qM4zNRYhoBfMSsJyXOsBvXYBvMqFwfMHjxd/xUys8ExIlkIg+867idCPJOmXkG8F e/ZXGEP+4MXaIls+NsU4 =kC6Y -----END PGP SIGNATURE----- |