From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id 1390A3838224; Wed, 22 Jun 2022 00:44:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1390A3838224 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] libstdc++: eh_globals: gthreads: reset _S_init before deleting key X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 139325673a3fc8c853267da4db165261f9c6138f X-Git-Newrev: 9a90a804bf901c2d6cf9ba93725c17e75d8f09ec Message-Id: <20220622004433.1390A3838224@sourceware.org> Date: Wed, 22 Jun 2022 00:44:33 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2022 00:44:33 -0000 https://gcc.gnu.org/g:9a90a804bf901c2d6cf9ba93725c17e75d8f09ec commit 9a90a804bf901c2d6cf9ba93725c17e75d8f09ec Author: Alexandre Oliva Date: Mon Jun 20 19:45:08 2022 -0300 libstdc++: eh_globals: gthreads: reset _S_init before deleting key 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. for libstdc++-v3/ChangeLog * libsupc++/eh_globals.cc [!_GLIBCXX_HAVE_TLS] (__eh_globals_init::~__eh_globals_init): Clear _S_init first. Diff: --- 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 768425c0f40..0aadb692a96 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;