From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E5F56385800B; Wed, 7 Feb 2024 18:21:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5F56385800B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707330115; bh=16MtPr8AVh524FnG7etTHPRMnMxdUWer1oQ8vR0mIxE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=shwJGXLgUQLhNnqULmxdrTpZX8cO6fajVhSeywJ5sUyBNAyZkq8YOVjQPY3WxAzjR Ouf9gMYnGwFeh8SGfGQSbuiwDLE/sZBGlnS2niG6CmG5cApd4yRCngL0x5mxkVyBOU NSjKY8iA3rspBncGd4qbngix9Cr9LXAr/jmJnY6c= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113724] [14 Regression][OpenMP] ICE (segfault) when mapping a struct in omp_gather_mapping_groups_1 Date: Wed, 07 Feb 2024 18:21:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code, openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113724 --- Comment #2 from Tobias Burnus --- Inside: omp_build_struct_sibling_lists new_next=20 =3D omp_accumulate_sibling_list (region_type, code, struct_map_to_clause, *grpmap, grp_start_p, grp_end, addr_token= s, &inner, &fragile_p, grp->reprocess_struct, &added_ta= il); This processing looks okay. But: /* Delete groups marked for deletion above. At this point the order of t= he groups may no longer correspond to the order of the underlying list, which complicates this a little. First clear out OMP_CLAUSE_DECL for deleted nodes... */ FOR_EACH_VEC_ELT (*groups, i, grp) if (grp->deleted) for (tree d =3D *grp->grp_start; d !=3D OMP_CLAUSE_CHAIN (grp->grp_end); d =3D OMP_CLAUSE_CHAIN (d)) OMP_CLAUSE_DECL (d) =3D NULL_TREE; Where we have the following 4 elements. Note that grp_start is identical for [1] and [2] =E2=80=93 where [2] is deleted =3D true =E2=80=93 which causes = that the CLAUSE_DECL are NULL. Namely, 'p (*groups)[i]' for i =3D 0...3 gives: $86 =3D (omp_mapping_group &) @0x30f7a48: {grp_start =3D 0x7ffff6c92070, gr= p_end =3D 0x7ffff71f96c0, mark =3D UNVISITED, deleted =3D false, reprocess_struct =3D= false, fragile =3D false, sibling =3D 0x0, next =3D 0x0} $91 =3D (omp_mapping_group &) @0x30f7a70: {grp_start =3D 0x7ffff71f96d0, gr= p_end =3D 0x7ffff71f9678, mark =3D UNVISITED, deleted =3D false, reprocess_struct =3D= false, fragile =3D false, sibling =3D 0x0, next =3D 0x0} $92 =3D (omp_mapping_group &) @0x30f7a98: {grp_start =3D 0x7ffff71f96d0, gr= p_end =3D 0x7ffff71f9630, mark =3D UNVISITED, deleted =3D true, reprocess_struct =3D = false, fragile =3D false, sibling =3D 0x0, next =3D 0x0} $93 =3D (omp_mapping_group &) @0x30f7ac0: {grp_start =3D 0x7ffff71f9640, gr= p_end =3D 0x7ffff71f9708, mark =3D UNVISITED, deleted =3D false, reprocess_struct =3D= false, fragile =3D false, sibling =3D 0x0, next =3D 0x0} Where the '*grp_start' values of [0],[1]+[2], [3] are: map(struct:S1 [len: 3]) map(tofrom:S1.a) map(tofrom:S1.b) map(alloc:S1.p [l= en: 8]) map(tofrom:*S1.p [len: 400]) map(attach_detach:S1.p [bias: 0]) map(tofrom:S1.p) map(alloc:S1.p [len: 8]) map(tofrom:*S1.p [len: 400]) map(attach_detach:S1.p [bias: 0]) map(tofrom:S1.p) (gdb) p debug(*(tree*)0x7ffff71f9640) And 'grp_end' for [0]...[4] is: map(tofrom:S1.b) map(alloc:S1.p [len: 8]) map(tofrom:*S1.p [len: 400]) map(attach_detach:S1.p [bias: 0]) map(tofrom:S1.p) map(tofrom:S1.a) map(tofrom:S1.b) map(alloc:S1.p [len: 8]) map(tofrom:*S1.p [len: 400]) map(attach_detach:S1.p [bias: 0]) map(tofrom:S1.p) map(tofrom:S1.p) map(attach_detach:S1.p [bias: 0]) map(tofrom:S1.p) BEFORE that deleted loop, the result is: (gdb) p debug(*list_p) map(struct:S1 [len: 3]) map(tofrom:S1.a) map(tofrom:S1.b) map(alloc:S1.p [l= en: 8]) map(tofrom:*S1.p [len: 400]) map(attach_detach:S1.p [bias: 0]) map(tofrom:S1.p) which looks fine. Obviously, after the deleted, all entries after 'alloc:S.= p' have CLAUSE_DECL =3D=3D NULL_TREE, causing the fail. * * * RFC: * Why are there two 'grp' with the same *grp_start value? * Why does it get set to 'deleted' while its clauses are actually used?=