public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/46455] New: shared_ptr consuming too many semaphores on Windows
@ 2010-11-12 19:45 internet at 123gen dot com
  2010-11-12 20:23 ` [Bug libstdc++/46455] " redi at gcc dot gnu.org
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: internet at 123gen dot com @ 2010-11-12 19:45 UTC (permalink / raw)
  To: gcc-bugs

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<string> x = make_shared<string>("test");
        shared_ptr<string> 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
<https://bugs.launchpad.net/dcplusplus/+bug/654040>.


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2011-03-31 17:59 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-12 19:45 [Bug libstdc++/46455] New: shared_ptr consuming too many semaphores on Windows internet at 123gen dot com
2010-11-12 20:23 ` [Bug libstdc++/46455] " redi at gcc dot gnu.org
2010-11-12 20:34 ` redi at gcc dot gnu.org
2010-11-12 20:59 ` internet at 123gen dot com
2010-11-12 23:07 ` redi at gcc dot gnu.org
2010-11-14 13:12 ` ktietz at gcc dot gnu.org
2010-11-14 17:54 ` redi at gcc dot gnu.org
2010-11-15 12:31 ` redi at gcc dot gnu.org
2010-11-15 13:45 ` internet at 123gen dot com
2010-11-15 13:59 ` internet at 123gen dot com
2010-11-15 14:25 ` redi at gcc dot gnu.org
2010-11-15 16:35 ` internet at 123gen dot com
2010-11-15 18:19 ` [Bug libstdc++/46455] resource leaks due to missing destructors for mutexes and condvars redi at gcc dot gnu.org
2010-11-15 18:38 ` paolo.carlini at oracle dot com
2010-11-15 19:00 ` redi at gcc dot gnu.org
2010-11-15 22:28 ` redi at gcc dot gnu.org
2010-11-16  0:53 ` redi at gcc dot gnu.org
2010-11-16  8:56 ` internet at 123gen dot com
2010-11-16 10:21 ` redi at gcc dot gnu.org
2010-11-16 10:35 ` paolo.carlini at oracle dot com
2010-11-16 11:16 ` redi at gcc dot gnu.org
2010-11-16 12:07 ` paolo.carlini at oracle dot com
2010-11-16 12:47 ` redi at gcc dot gnu.org
2010-11-16 21:46 ` redi at gcc dot gnu.org
2010-11-16 22:30 ` internet at 123gen dot com
2010-11-16 22:53 ` redi at gcc dot gnu.org
2010-11-16 23:03 ` redi at gcc dot gnu.org
2010-11-16 23:27 ` redi at gcc dot gnu.org
2010-11-16 23:38 ` redi at gcc dot gnu.org
2010-11-17  7:42 ` internet at 123gen dot com
2010-11-17  9:41 ` redi at gcc dot gnu.org
2010-11-17 22:23 ` redi at gcc dot gnu.org
2010-11-17 22:54 ` internet at 123gen dot com
2010-11-18  0:11 ` paolo.carlini at oracle dot com
2010-11-18  0:31 ` redi at gcc dot gnu.org
2010-11-18  5:39 ` redi at gcc dot gnu.org
2010-11-18 18:58 ` redi at gcc dot gnu.org
2010-11-18 19:49 ` redi at gcc dot gnu.org
2011-03-31 18:39 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).