public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/113867] [14 Regression][OpenMP] Wrong code with mapping pointers in structs
Date: Mon, 12 Feb 2024 12:30:27 +0000	[thread overview]
Message-ID: <bug-113867-4-BfTMQk7FWN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113867-4@http.gcc.gnu.org/bugzilla/>

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |burnus at gcc dot gnu.org
          Component|middle-end                  |libgomp

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The problem here is in libgomp's gomp_map_vars_internal:

                /* Fallthrough.  */
              case GOMP_MAP_STRUCT:
                first = i + 1;
                last = i + sizes[i];
                cur_node.host_start = (uintptr_t) hostaddrs[i];
                cur_node.host_end = (uintptr_t) hostaddrs[last]
                                    + sizes[last];
                if (tgt->list[first].key != NULL)
                  continue;
                if (sizes[last] == 0)
                  cur_node.host_end++;
                n = splay_tree_lookup (mem_map, &cur_node);
                if (sizes[last] == 0)
                  cur_node.host_end--;
                if (n == NULL && cur_node.host_start == cur_node.host_end)
                  {
                    gomp_mutex_unlock (&devicep->lock);
                    gomp_fatal ("Struct pointer member not mapped (%p)",
                                (void*) hostaddrs[first]);
                  }
                if (n == NULL)
...
                    field_tgt_base = (uintptr_t) hostaddrs[first];
...
                    field_tgt_clear = last;

here: n == NULL and cur_node.host_end - cur_node.host_start = 8 [i.e.
sizeof(void*)?!]:

For i=1, there is no action to be taken due to the
GOMP_MAP_ZERO_LEN_ARRAY_SECTION.

And for i=2,

                if (field_tgt_clear != FIELD_TGT_EMPTY)
                  {
                    k->tgt_offset = k->host_start - field_tgt_base
                                    + field_tgt_offset;

Here, k->tgt_offset = hostaddr of the struct but we are no longer mapping a
struct here. - Clearly, resetting was forgotten ...

  parent reply	other threads:[~2024-02-12 12:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-10 18:01 [Bug middle-end/113867] New: " burnus at gcc dot gnu.org
2024-02-10 18:07 ` [Bug middle-end/113867] " burnus at gcc dot gnu.org
2024-02-12  8:45 ` rguenth at gcc dot gnu.org
2024-02-12 12:30 ` burnus at gcc dot gnu.org [this message]
2024-02-12 13:00 ` [Bug libgomp/113867] " burnus at gcc dot gnu.org
2024-02-13 10:43 ` burnus at gcc dot gnu.org
2024-02-21 17:59 ` burnus at gcc dot gnu.org
2024-03-07 20:40 ` law at gcc dot gnu.org
2024-04-03 12:02 ` rguenth at gcc dot gnu.org
2024-04-26  8:42 ` jakub at gcc dot gnu.org
2024-05-07  7:45 ` [Bug libgomp/113867] [14/15 " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113867-4-BfTMQk7FWN@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).