public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wilco at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/110773] [Aarch64] crash (SIGBUS) due to atomic instructions on under-aligned memory
Date: Thu, 04 Apr 2024 10:59:56 +0000	[thread overview]
Message-ID: <bug-110773-4-SlzwcO8epz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110773-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Sainan from comment #3)
> I seem to be having a related issue, although in my case the struct looks
> like this:
> 
> template <typename T>
> struct Data
> {
>     T* data;
>     std::atomic_uint count;
>     bool flag;
> };
> 
> And it's crashing on `--count;`
> 
> Surely this is not a user issue in this case because the pointer should
> always be 8 bytes, so count should be evenly aligned on a 8-byte boundary.
> (Unless the atomic operation needs 16-byte alignment?)

The atomic will also set correct struct alignment.

> Same code also runs fine when compiled via MSVC and run on Windows, although
> it's unclear if this might simply be my Linux test machine running an older
> ARM CPU compared to my Windows on ARM test machine.

You would get a crash if you build for LSE so you get a LDADDAL instruction and
then run it on a CPU that doesn't. So try -mcpu=native and it should work.

  parent reply	other threads:[~2024-04-04 10:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 23:46 [Bug target/110773] New: " scw-gcc at google dot com
2023-07-22  0:02 ` [Bug middle-end/110773] " pinskia at gcc dot gnu.org
2023-09-07 14:38 ` wilco at gcc dot gnu.org
2024-04-04 10:44 ` sainan+gcc.bugzilla at calamity dot gg
2024-04-04 10:59 ` wilco at gcc dot gnu.org [this message]
2024-04-04 17:09 ` sainan+gcc.bugzilla at calamity dot gg
2024-04-04 17:25 ` wilco at gcc dot gnu.org
2024-04-04 17:45 ` sainan+gcc.bugzilla at calamity dot gg
2024-04-04 17:54 ` wilco at gcc dot gnu.org
2024-04-04 18:01 ` sainan+gcc.bugzilla at calamity dot gg

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-110773-4-SlzwcO8epz@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).