public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-12] In 'libgomp/allocator.c:omp_realloc', route 'free' through 'MEMSPACE_FREE'
@ 2023-02-16 21:42 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-02-16 21:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3a2c07395b0a565955a7b86f0eba866937e15989

commit 3a2c07395b0a565955a7b86f0eba866937e15989
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Feb 14 13:35:03 2023 +0100

    In 'libgomp/allocator.c:omp_realloc', route 'free' through 'MEMSPACE_FREE'
    
    ... 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'.

Diff:
---
 libgomp/ChangeLog.omp |  2 ++
 libgomp/allocator.c   | 12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 530f5c6acf6..819a5333907 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -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.
diff --git a/libgomp/allocator.c b/libgomp/allocator.c
index 05b323d458e..ba9a4e17cc2 100644
--- a/libgomp/allocator.c
+++ b/libgomp/allocator.c
@@ -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:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-16 21:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 21:42 [gcc/devel/omp/gcc-12] In 'libgomp/allocator.c:omp_realloc', route 'free' through 'MEMSPACE_FREE' Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).