https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93065
Bug ID: 93065 Summary: libgomp: destructor missing to delete goacc_cleanup_key Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: v.narang at samsung dot com CC: jakub at gcc dot gnu.org Target Milestone: --- 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. Test Code: #include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int main(int argc, char **argv) { void *handle; double (*cosine)(double); char *error; while(1) { handle = dlopen("/usr/lib/libgomp.so", RTLD_LAZY); if (!handle) { fprintf(stderr, "%s\n", dlerror()); exit(EXIT_FAILURE); } dlclose(handle); } exit(EXIT_SUCCESS); } Test Logs: $./a.out libgomp: could not create thread pool destructor