aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2019-01-24 14:12:19 +0000
committerTom de Vries <vries@gcc.gnu.org>2019-01-24 14:12:19 +0000
commit738c56d4104867713d8fe64dd0ddbdef56f9c67b (patch)
tree6accba5f52360417d24f463315367a1eb43c4be8 /libgomp
parent0e2eb6abeb77d86e672f0872bca5dd3528134734 (diff)
downloadgcc-738c56d4104867713d8fe64dd0ddbdef56f9c67b.zip
gcc-738c56d4104867713d8fe64dd0ddbdef56f9c67b.tar.gz
gcc-738c56d4104867713d8fe64dd0ddbdef56f9c67b.tar.bz2
[nvptx, libgomp] Fix memleak in GOMP_OFFLOAD_fini_device
I wrote a test-case: ... int main (void) { for (unsigned i = 0; i < 128; ++i) { acc_init (acc_device_nvidia); acc_shutdown (acc_device_nvidia); } return 0; } ... and ran it under valgrind. The only leak location reported with a frequency of 128, was the allocation of ptx_devices in nvptx_init. Fix this by freeing ptx_devices in GOMP_OFFLOAD_fini_device, once instantiated_devices drops to 0. 2019-01-24 Tom de Vries <tdevries@suse.de> * plugin/plugin-nvptx.c (GOMP_OFFLOAD_fini_device): Free ptx_devices once instantiated_devices drops to 0. From-SVN: r268237
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/plugin/plugin-nvptx.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 660fc92..fb69402 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-24 Tom de Vries <tdevries@suse.de>
+
+ * plugin/plugin-nvptx.c (GOMP_OFFLOAD_fini_device): Free ptx_devices
+ once instantiated_devices drops to 0.
+
2019-01-23 Tom de Vries <tdevries@suse.de>
PR target/PR88946
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index ff90b67..387e7cc 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -1936,6 +1936,12 @@ GOMP_OFFLOAD_fini_device (int n)
instantiated_devices--;
}
+ if (instantiated_devices == 0)
+ {
+ free (ptx_devices);
+ ptx_devices = NULL;
+ }
+
pthread_mutex_unlock (&ptx_dev_lock);
return true;
}