public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/95722] New: libatomic crashes on __atomic_load of const object
@ 2020-06-17 14:55 luis at luismarques dot eu
  2020-06-17 19:10 ` [Bug target/95722] " foom at fuhm dot net
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: luis at luismarques dot eu @ 2020-06-17 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

            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 = a;
}
```

On x86_64 I get:

```
$ gcc test.c -latomic && ./a.out 
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 crash.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-28 20:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 14:55 [Bug other/95722] New: libatomic crashes on __atomic_load of const object luis at luismarques dot eu
2020-06-17 19:10 ` [Bug target/95722] " foom at fuhm dot net
2020-06-18  8:30 ` [Bug c/95722] " rguenth at gcc dot gnu.org
2020-06-18 16:16 ` joseph at codesourcery dot com
2021-08-28 20:55 ` [Bug target/95722] " pinskia 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).