Delete the pthread key on cleanup in TLS mode
authorMartin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Sat, 29 Dec 2018 20:59:31 +0000 (21:59 +0100)
committerGitHub <noreply@github.com>
Sat, 29 Dec 2018 20:59:31 +0000 (21:59 +0100)
to avoid a crash when OpenBLAS was loaded via dlopen and libc tries to clean up the leaked TLS after dlclose
Fixes #1720

driver/others/memory.c

index 36815a3..6f7a7db 100644 (file)
@@ -1073,6 +1073,11 @@ static volatile int memory_initialized = 0;
     }
     free(table);
   }
+#if defined(OS_WINDOWS)
+  TlsFree(local_storage_key);
+#else
+  pthread_key_delete(local_storage_key);
+#endif         
 }
 
 static void blas_memory_init(){