libgfortran thread-safety
Janne Blomqvist
blomqvist.janne@gmail.com
Sat Feb 5 20:51:00 GMT 2011
Hi,
as a result of a bunch of recent and not-so-recent patches by yours
truly fixing localtime, gmtime, ctime, strerror, ttyname, and
getpwuid, libgfortran now uses thread-safe POSIX functions where
available instead of the non-thread-safe variants. There are, however,
two exceptions, namely getenv() and system(), which POSIX does not
require to be thread-safe nor provides any thread-safe alternatives.
- getenv() is used during library initialization, and by the GETENV
and GET_ENVIRONMENT_VARIABLE intrinsics. It is up to the user to
ensure that the program does not concurrently modify the environment
with any of these actions. In practice, few if any applications modify
their environment.
- system() is used by the SYSTEM and EXECUTE_COMMAND_LINE intrinsics.
There might be a race condition if multiple threads modify the signal
masks of the parent in the system() implementation? Secondly, it's
unspecified whether pthread_atfork() handlers run or not.
I tested the list of thread-unsafe functions with a slightly modified
version (using readelf to check symbols instead of grepping directly)
of the script at
http://blog.josefsson.org/2009/06/23/thread-safe-functions/
I don't this is anything worth bragging about in the release notes,
but perhaps some note could be put into the documentation?
--
Janne Blomqvist
More information about the Fortran
mailing list