public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/65343] unexpected exception thrown during destruction of static object in debug mode
Date: Tue, 25 Jan 2022 20:58:25 +0000	[thread overview]
Message-ID: <bug-65343-4-6EBVZxVftp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65343-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65343

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Patch for stage 1:

--- a/libstdc++-v3/src/c++11/shared_ptr.cc
+++ b/libstdc++-v3/src/c++11/shared_ptr.cc
@@ -28,6 +28,11 @@

 namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
 {
+  namespace
+  {
+    alignas(64) unsigned char __mutex_storage[64 * (mask + 1)];
+  }
+
   /* Returns different instances of __mutex depending on the passed index
    * in order to limit contention.
    */
@@ -36,7 +41,7 @@ namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
   {
     // increase alignment to put each lock on a separate cache line
     struct alignas(64) M : __gnu_cxx::__mutex { };
-    static M m[mask + 1];
+    static M* m = ::new(__mutex_storage) M[mask + 1];
     return m[i];
   }
 }

  parent reply	other threads:[~2022-01-25 20:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-07 13:29 [Bug libstdc++/65343] New: " frankhb1989 at gmail dot com
2015-03-10 12:25 ` [Bug libstdc++/65343] " frankhb1989 at gmail dot com
2022-01-25 14:52 ` poulhies at adacore dot com
2022-01-25 17:30 ` ebotcazou at gcc dot gnu.org
2022-01-25 20:58 ` redi at gcc dot gnu.org [this message]
2022-01-25 21:35 ` poulhies at adacore dot com
2022-01-25 21:36 ` redi at gcc dot gnu.org
2022-01-25 21:38 ` redi at gcc dot gnu.org
2024-02-08 12:40 ` 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-65343-4-6EBVZxVftp@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).