[Bug libstdc++/12855] Thread safety problems in ios_base::Init
carlo at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sun Dec 14 03:45:00 GMT 2003
------- Additional Comments From carlo at gcc dot gnu dot org 2003-12-14 03:45 -------
There is another problem with the patch.
As the old comments state:
// NB: Allows debugger applications use of the standard streams
! // from operator new. _S_ios_base_init must be incremented in
! // _S_ios_create _after_ initialization is completed.
static bool
! _S_initialized() { return _S_ios_base_init; }
the flag that things are initialized must be set
AFTER things are initialized. You'd break this function
with your patch:
*************** namespace std
*** 80,86 ****
ios_base::Init::Init()
{
! if (_S_ios_base_init == 0)
{
// Standard streams default to synced with "C" operations.
_S_synced_with_stdio = true;
--- 80,86 ----
ios_base::Init::Init()
{
! if (__exchange_and_add(&_S_references, 1) == 0)
{
// Standard streams default to synced with "C" operations.
_S_synced_with_stdio = true;
*************** namespace std
*** 110,124 ****
wcin.tie(&wcout);
wcerr.flags(ios_base::unitbuf);
#endif
-
- _S_ios_base_init = 1;
}
- ++_S_ios_base_init;
}
As this increments _S_references at the beginning
and not at the end.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12855
More information about the Gcc-bugs
mailing list