From: Alexandre Oliva <oliva@adacore.com>
To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: [PATCH] libstdc++: eh_globals: gthreads: reset _S_init before deleting key
Date: Tue, 21 Jun 2022 03:03:41 -0300 [thread overview]
Message-ID: <orh74ed03m.fsf@lxoliva.fsfla.org> (raw)
Clear __eh_globals_init's _S_init in the dtor before deleting the
gthread key.
This ensures that, in case any code involved in deleting the key
interacts with eh_globals, the key that is being deleted won't be
used, and the non-thread-specific eh_globals fallback will.
Regstrapped on x86_64-linux-gnu, also tested with a cross to
aarch64-rtems6. Ok to install?
PS: This is a fix for a theoretical issue, that came to mind while I
independently investigated the problem that I later found to be
PR105880.
for libstdc++-v3/ChangeLog
* libsupc++/eh_globals.cc [!_GLIBCXX_HAVE_TLS]
(__eh_globals_init::~__eh_globals_init): Clear _S_init first.
---
libstdc++-v3/libsupc++/eh_globals.cc | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/libsupc++/eh_globals.cc b/libstdc++-v3/libsupc++/eh_globals.cc
index 768425c0f407a..0aadb692a9625 100644
--- a/libstdc++-v3/libsupc++/eh_globals.cc
+++ b/libstdc++-v3/libsupc++/eh_globals.cc
@@ -119,8 +119,13 @@ struct __eh_globals_init
~__eh_globals_init()
{
if (_S_init)
- __gthread_key_delete(_M_key);
- _S_init = false;
+ {
+ /* Set it before the call, so that, should
+ __gthread_key_delete throw an exception, it won't rely on
+ the key being deleted. */
+ _S_init = false;
+ __gthread_key_delete(_M_key);
+ }
}
__eh_globals_init(const __eh_globals_init&) = delete;
--
Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/
Free Software Activist GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts. Ask me about <https://stallmansupport.org>
next reply other threads:[~2022-06-21 6:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 6:03 Alexandre Oliva [this message]
2022-06-21 7:40 ` Jonathan Wakely
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=orh74ed03m.fsf@lxoliva.fsfla.org \
--to=oliva@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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).