[BUG: 93065] libgomp: destructor missing to delete goacc_cleanup_key libgomp constructor creates goacc_cleanup_key on dlopen but doesn't delete key on dlclose. dlopen and dlclose of libgomp.so exhausts pthread keys, which results in pthread_key_create failure.
pthread_key_delete needs to be called by libgomp destructor. Signed-off-by: Vaneet Narang <v.nar...@samsung.com> Signed-off-by: Ayush Mittal <ayus...@samsung.com> --- [v2 patch] https://gcc.gnu.org/ml/gcc-bugs/2019-12/msg02326.html [v2] -> [v3] * Adding entry in libgomp/ChangeLog instead of toplevel Changelog. libgomp/ChangeLog | 4 ++++ libgomp/oacc-init.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 9eb3e2c25a0..a661685a5c2 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2019-12-31 Ayush Mittal <ayus...@samsung.com> + + * oacc-init.c (goacc_runtime_deinitialize): New function. + 2019-12-28 Jakub Jelinek <ja...@redhat.com> PR bootstrap/93074 diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c index 487a2cca61f..6aa5fd297d6 100644 --- a/libgomp/oacc-init.c +++ b/libgomp/oacc-init.c @@ -858,6 +858,15 @@ goacc_runtime_initialize (void) goacc_host_init (); } +static void __attribute__((destructor)) +goacc_runtime_deinitialize (void) +{ +#if !(defined HAVE_TLS || defined USE_EMUTLS) + pthread_key_delete (goacc_tls_key); +#endif + pthread_key_delete (goacc_cleanup_key); +} + /* Compiler helper functions */ attribute_hidden void -- 2.17.1