From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14494 invoked by alias); 14 Dec 2003 03:45:26 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14487 invoked by uid 48); 14 Dec 2003 03:45:26 -0000 Date: Sun, 14 Dec 2003 03:45:00 -0000 Message-ID: <20031214034526.14486.qmail@sources.redhat.com> From: "carlo at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20031031094301.12855.peturr02@ru.is> References: <20031031094301.12855.peturr02@ru.is> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libstdc++/12855] Thread safety problems in ios_base::Init X-Bugzilla-Reason: CC X-SW-Source: 2003-12/txt/msg01492.txt.bz2 List-Id: ------- 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