On 05/24/2011 03:39 PM, Bruno Haible wrote:
>   1) In code that ends up in lisp.run (e.g. errunix.d). This executable has
>      the option to use multiple threads. Therefore strerror_r should be
>      used instead of strerror(), because - as Eric explained - when you
>      call strerror(EACCES) in one thread and strerror(ENOENT) in another
>      thread at nearly the same time, by the time you retrieve the error 
> message
>      in the first thread, it might read "Permissionle or directory".
>      YES, even for fixed error messages, strerror() uses a static buffer
>      in the majority of OSes (at least on NetBSD, HP-UX, native Win32, 
> Cygwin).

Not cygwin (it uses a thread-local buffer for "Unknown error", and
direct string pointers for known errors), but I can indeed confirm that
FreeBSD 8.2 returns the same pointer for multiple strerror() results,
and if that pointer is not thread-local, you have problems in a
multi-threaded app.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to