Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
In many places in the VM code if we detect an error from a library call we use strerror(errno) to produce a human-readable description of the error. Unfortunately strerror may not be thread-safe, particularly when the content is localized, due to use of a static buffer: DESCRIPTION The strerror() function returns a pointer to a string that describes the error code passed in the argument errnum, possibly using the LC_MESSAGES part of the current locale to select the appropriate language. This string must not be modified by the application, but may be modified by a subsequent call to perror(3) or strerror(). No library function will modify this string. The strerror_r() function is similar to strerror(), but is thread safe. This function is available in two versions: an XSI-compliant version specified in POSIX.1-2001 (available since glibc 2.3.4), and a GNU-specific version (available since glibc 2.0). ---- Switching to strerror_r seems reasonable, but some usage contexts make it difficult to define a local buffer - in particular unified-logging expressions where we don't want to have to define the buffer if logging is not enabled. Simple wrapping of the call also doesn't work as we can't use the buffer after the call returns.
|