This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/12855] Thread safety problems in ios_base::Init
- From: "carlo at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Dec 2003 03:45:26 -0000
- Subject: [Bug libstdc++/12855] Thread safety problems in ios_base::Init
- References: <20031031094301.12855.peturr02@ru.is>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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