On Sat, May 7, 2011 at 19:35, Janne Blomqvist <blomqvist.ja...@gmail.com> wrote: > Hi, > > the error printing functionality (in io/unix.c) st_printf and > st_vprintf are not thread-safe as they use a static buffer. However, > since these routines are used when something has gone wrong, we > shouldn't use malloc() to allocate thread-specific buffers or anything > fancy like that. The way the buffer is used is that it is filled with > vs(n)printf() and then the buffer is written using write(); the > simplest way to fix this is to just print directly using vfprintf(), > which is what this patch does. Also, the patch uses > flockfile/funlockfile in a few places to increase the likelihood of > multiple related messages to end up together on the output. > > As stderr is unbuffered and stdout is buffered, this patch also gets > rid of the functionality to choose where to send the error output, as > we don't want to deal with buffering in the error handling path. IMHO > this is no loss, as all targets/shells/batch schedulers/ etc. where > this might be relevant, offer functionality to redirect stderr to > wherever stdout goes. So there is no need for a gfortran-specific > mechanism for this.
While this patch makes error printing thread-safe, it's no longer async-signal-safe as the stderr lock might lead to a deadlock. So I'm retracting this patch and thinking some more about this problem. -- Janne Blomqvist