This is the mail archive of the
mailing list for the libstdc++ project.
reentrancy and cout/stdout
- To: libstdc++ at gcc dot gnu dot org
- Subject: reentrancy and cout/stdout
- From: Joel Sherrill <joel at OARcorp dot com>
- Date: Wed, 20 Jun 2001 17:10:15 -0500
I am tracking down a problem in a multi-threaded run-time in which it
the FILE * associated with cout is cached internally to libio. This is
libio shipped with gcc 2.95.2. I do not have a working gcc 3.0 to
RTEMS uses the newlib reentrancy structure on a per-thread basis.
Each thread gets its own stdin, out, and err structures. The symptom is
that "task2" is using the correct reentrancy structure but tries to fwrite()
using the FILE * associated "task1". Since the reentrancy structure and
belong to different tasks, there is an accounting conflict.
I think the underlying cause is that somewhere in the bowels, libio is
grabbing a FILE * pointer and using its own local copy rather than
repeatedly using "stdout". In this system, stdout is a macro defined as:
stdio.h:#define stdout (_impure_ptr->_stdout)
So if libio assigns that to an internal variable, then that stdout ends up
being used by all tasks.
Does this description make sense? Is this the behavior in v3? Is there
a way to fix this on either side?