From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 75BDF38930D7; Wed, 17 Jun 2020 14:55:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75BDF38930D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592405710; bh=t+Y2g7coErJY+LZYxgrgag8z+ip31Pz28OQfE8XTl6k=; h=From:To:Subject:Date:From; b=R7dza9ai1AWpvce4Sz8+l36FNlrztH9lxAexpMaP4uXuTz/gJ62L3LfRkCpdvVe4Q 1NAKS/bnBt7y/aeXmYy0OxMy5/Yug5LPh1rfmjzUNwwFpo+2k6OQaePg+OaKD9kMCZ N3V+SWuahoC+6C5XYMVUI2VrwSipnfVrUtZwc2gQ= From: "luis at luismarques dot eu" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/95722] New: libatomic crashes on __atomic_load of const object Date: Wed, 17 Jun 2020 14:55:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luis at luismarques dot eu 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 14:55:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95722 Bug ID: 95722 Summary: libatomic crashes on __atomic_load of const object Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: luis at luismarques dot eu Target Milestone: --- With this code in `test.c`: ``` struct S { int x; int y; int z; }; int main() { __attribute__((aligned(16))) static const _Atomic struct S a; struct S b; b =3D a; } ``` On x86_64 I get: ``` $ gcc test.c -latomic && ./a.out=20 Segmentation fault (core dumped) ``` It crashes on a `lock cmpxchg16b` with the address of `a`, so I imagine the libatomic implementation is dispatching to an optimized __atomic_load case where the code assumes it can get a (mutable) lock from the object itself, = and when it tries to acquire that lock it writes to `.rodata`, causing the cras= h.=