[Bug fortran/120286] [13/14/15/16 regression] [OpenMP] Double free detected when using openmp
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 18 02:21:18 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120286
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jerry DeLisle
<jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:cdf4e7361118872696353b24acf964b7f4b0ea03
commit r15-10986-gcdf4e7361118872696353b24acf964b7f4b0ea03
Author: Christopher Albert <albert@tugraz.at>
Date: Tue Mar 10 20:59:48 2026 +0100
fortran: Preserve scalar class pointers in OpenMP privatization [PR120286]
OpenMP privatization currently treats scalar class pointers like owned
polymorphic class objects. In the worker cleanup for private/firstprivate
class pointers, the generated code finalizes and frees ptr._data even
though
the clause only copied pointer association status from a shared target.
Fix this in gfc_omp_clause_copy_ctor and gfc_omp_clause_dtor by unwrapping
saved descriptors first and by recognizing class-pointer container types
locally in those hooks. That keeps scalar class pointers on the
association-only path without changing the broader polymorphic mapping
classification used for OpenMP warnings and deep mapping.
Add a runtime regression test for the original private(ptr) crash plus a
firstprivate(ptr) association check.
gcc/fortran/ChangeLog:
PR fortran/120286
* trans-openmp.cc (gfc_is_class_pointer_type): New helper.
(gfc_omp_clause_copy_ctor): Unwrap saved descriptors before
deciding whether privatization should preserve only pointer
association. Handle scalar class pointers on that path too.
(gfc_omp_clause_dtor): Likewise.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/pr120286.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
(cherry picked from commit 60fbabc1a182cca77d14c68a1b623c554310d135)
More information about the Gcc-bugs
mailing list