public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "internet at 123gen dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/46455] shared_ptr consuming too many semaphores on Windows
Date: Mon, 15 Nov 2010 13:59:00 -0000 [thread overview]
Message-ID: <bug-46455-4-WJBrBfCQ7B@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-46455-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46455
--- Comment #9 from Zouzou <internet at 123gen dot com> 2010-11-15 13:46:33 UTC ---
(In reply to comment #7)
> Could you try this, which is a simplified version of the shared_ptr refcounting
> code and should have the same behaviour:
> #include <ext/atomicity.h>
> #include <ext/concurrence.h>
> #include <assert.h>
> static int count0 = 0;
> struct X
> {
> X() : count1(1), count2(1) { ++count0; }
> ~X() { assert( count1==0 ); assert( count2==0 ); --count0; }
> void release()
> {
> if (__gnu_cxx::__exchange_and_add_dispatch(&count1, -1) == 1)
> {
> if (__gnu_cxx::__exchange_and_add_dispatch(&count2, -1) == 1)
> delete this;
> }
> }
> __gnu_cxx::__mutex m;
> _Atomic_word count1;
> _Atomic_word count2;
> };
> int main()
> {
> for (int i=0; i<100; ++i)
> {
> X* x = new X;
> x->release();
> }
> assert( count0 == 0 );
> }
[i added a Sleep(100) call after x->release(); for easier diagnostics.]
this code produces the same behavior as my test case (increasing number of
semaphores, over 100 after 10 seconds) on both vanilla MinGW and mingw64.
to summarize: my test case (standard shared_ptr creation) worked fine on
mingw64 (which has a __gnu_cxx::__default_lock_policy = 2) but bugged on
vanilla MinGW (which has a __gnu_cxx::__default_lock_policy = 1); but this one
produces the bug in both cases.
next prev parent reply other threads:[~2010-11-15 13:53 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-12 19:45 [Bug libstdc++/46455] New: " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-46455-4-WJBrBfCQ7B@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).