From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 9DC353858015; Fri, 19 Nov 2021 14:15:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DC353858015 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain Buclaw To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9832] libphobos: Don't call __gthread_key_delete in the emutls destroy function. X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 4c89730ae826980b31d2e27d64616b00fb0f752e X-Git-Newrev: e8005eb1bf061cc5fd7d9f32f721d99b450449f6 Message-Id: <20211119141530.9DC353858015@sourceware.org> Date: Fri, 19 Nov 2021 14:15:30 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 14:15:30 -0000 https://gcc.gnu.org/g:e8005eb1bf061cc5fd7d9f32f721d99b450449f6 commit r9-9832-ge8005eb1bf061cc5fd7d9f32f721d99b450449f6 Author: Iain Buclaw Date: Fri Nov 19 14:26:07 2021 +0100 libphobos: Don't call __gthread_key_delete in the emutls destroy function. Fixes a EXC_BAD_ACCESS issue seen on Darwin when the libphobos DSO gets unloaded. Based on reading libgcc's emutls implementation, as it doesn't call __gthread_key_delete directly, neither should libphobos. libphobos/ChangeLog: * libdruntime/gcc/emutls.d (emutlsDestroyThread): Don't remove entry from global array. (_d_emutls_destroy): Don't call __gthread_key_delete. (cherry picked from commit 910d2b4b7513b6bfe02777d44cd5377c22198086) Diff: --- libphobos/libdruntime/gcc/emutls.d | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libphobos/libdruntime/gcc/emutls.d b/libphobos/libdruntime/gcc/emutls.d index 461f20d9e28..72376ecda0f 100644 --- a/libphobos/libdruntime/gcc/emutls.d +++ b/libphobos/libdruntime/gcc/emutls.d @@ -229,9 +229,6 @@ void** emutlsAlloc(shared __emutls_object* obj) nothrow @nogc extern (C) void emutlsDestroyThread(void* ptr) nothrow @nogc { auto arr = cast(TlsArray*) ptr; - emutlsMutex.lock_nothrow(); - emutlsArrays.remove(arr); - emutlsMutex.unlock_nothrow(); foreach (entry; *arr) { @@ -308,9 +305,6 @@ void _d_emutls_scan(scope void delegate(void* pbeg, void* pend) nothrow cb) noth // Call this after druntime has been unloaded void _d_emutls_destroy() nothrow @nogc { - if (__gthread_key_delete(emutlsKey) != 0) - abort(); - (cast(Mutex) _emutlsMutex.ptr).__dtor(); destroy(emutlsArrays); }