From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23433 invoked by alias); 12 Nov 2010 19:42:49 -0000 Received: (qmail 23411 invoked by uid 22791); 12 Nov 2010 19:42:48 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Nov 2010 19:41:51 +0000 From: "internet at 123gen dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/46455] New: shared_ptr consuming too many semaphores on Windows X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: internet at 123gen dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 12 Nov 2010 19:45:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-11/txt/msg01703.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46455 Summary: shared_ptr consuming too many semaphores on Windows Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: internet@123gen.com Created attachment 22383 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22383 test case hello, i have just hit a bug in the implementation of shared_ptr in GCC 4.5 on Windows. the bug wasn't present in GCC 4.4. the bug is also specific to libstdc++: when using boost or MSVC, there is no problem. basically, any creation of a shared_ptr increases the amount of semaphores used by the process. this can be viewed by running the Task Manager and looking into the "Handles" column. the semaphores are never released and the count therefore keeps increasing without rest. the following simple prog shows it: int main() { int n=0; while (++n < 100) { //shared_ptr x = make_shared("test"); shared_ptr x(new string("test")); Sleep(100); } return 0; } (using either make_shared or the constructor doesn't make a difference.) when running it, you will notice a steady increase of the amount of handles, reaching more than 100 handles after 10 seconds. compile the same prog with MSVC or GCC 4.4 and notice that the amount of handles doesn't grow. of course, for this simple example, it is inoffensive, but programs that make a more important use of shared_ptr can quickly run out of available handles and crash in unexpected ways. for reference, the whole discussion is on .