]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
In 'libgomp/allocator.c:omp_realloc', route 'free' through 'MEMSPACE_FREE'
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 14 Feb 2023 12:35:03 +0000 (13:35 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 16 Feb 2023 21:42:00 +0000 (22:42 +0100)
... to not run into a SIGSEGV if a non-'malloc'-based allocation is 'free'd
here.

Fix-up for og12 commit c5d1d7651297a273321154a5fe1b01eba9dcf604
"libgomp, nvptx: low-latency memory allocator".

libgomp/
* allocator.c (omp_realloc): Route 'free' through 'MEMSPACE_FREE'.

libgomp/ChangeLog.omp
libgomp/allocator.c

index 530f5c6acf639c566c5edb344840edb0743146a1..819a533390752191f7295c25566143c6c9c3809b 100644 (file)
@@ -1,5 +1,7 @@
 2023-02-16  Thomas Schwinge  <thomas@codesourcery.com>
 
+       * allocator.c (omp_realloc): Route 'free' through 'MEMSPACE_FREE'.
+
        * config/linux/allocator.c (linux_memspace_alloc)
        (linux_memspace_calloc): Clarify zero-initialization for pinned
        memory.
index 05b323d458e22ed689019538260863ec5987eda2..ba9a4e17cc2077ba2bcc67ee88bf7cc6180da6b3 100644 (file)
@@ -854,7 +854,17 @@ retry:
       gomp_mutex_unlock (&free_allocator_data->lock);
 #endif
     }
-  free (data->ptr);
+  {
+    omp_memspace_handle_t was_memspace __attribute__((unused))
+      = (free_allocator_data
+        ? free_allocator_data->memspace
+        : predefined_alloc_mapping[free_allocator]);
+    int was_pinned __attribute__((unused))
+      = (free_allocator_data
+        ? free_allocator_data->pinned
+        : free_allocator == ompx_pinned_mem_alloc);
+    MEMSPACE_FREE (was_memspace, data->ptr, data->size, was_pinned);
+  }
   return ret;
 
 fail: