[committed] libphobos: Don't call __gthread_key_delete in the emutls destroy function.
Iain Buclaw
ibuclaw@gdcproject.org
Fri Nov 19 14:06:37 GMT 2021
Hi,
This patch 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.
Bootstrapped and regression tested on x86_64-linux-gnu and
x86_64-apple-darwin20, committed to mainline, and backported to the
release branches.
Regards,
Iain
---
libphobos/ChangeLog:
* libdruntime/gcc/emutls.d (emutlsDestroyThread): Don't remove entry
from global array.
(_d_emutls_destroy): Don't call __gthread_key_delete.
---
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 4237dc7a3df..462230508ab 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);
}
--
2.30.2
More information about the Gcc-patches
mailing list