public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/105538] New: [OpenMP] ALLOCA - MALLOC issue with firstprivate
@ 2022-05-09 18:25 burnus at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: burnus at gcc dot gnu.org @ 2022-05-09 18:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105538

            Bug ID: 105538
           Summary: [OpenMP] ALLOCA - MALLOC issue with firstprivate
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

The following fails with host fallback:

character(len=:), allocatable :: x(:)

x = ["abc", "cde"]

!$omp target firstprivate(x)
  x = ["abcx", "cdel", "hhgj"]
!$omp end target
end

The problem is:

          calculate_firstprivate_requirements (mapnum, hostaddrs, sizes, kinds,
                                               &tgt_align, &tgt_size);
          if (tgt_align)
            {
              char *tgt = gomp_alloca (tgt_size + tgt_align - 1);
              copy_firstprivate_data (tgt, mapnum, hostaddrs, sizes, kinds,
                                      tgt_align, tgt_size);
            }

firstprivate() now points inside the  alloca  area and the realloc now fails as
it wasn't malloced.


Question: Is this code valid (I think it is). Is so:

Expected: We possibly need some way to tag memory which should be 'malloc'ed
and not alloca'ed – possibly also with a user-specified allocator (or is this
only permitted for 'private'?) And use that with firstprivate instead.

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

only message in thread, other threads:[~2022-05-09 18:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 18:25 [Bug libgomp/105538] New: [OpenMP] ALLOCA - MALLOC issue with firstprivate burnus at gcc dot gnu.org

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).