From: Andrew Pinski <pinskia@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Sergey Bugaev <bugaevc@gmail.com>,
libc-alpha@sourceware.org, Florian Weimer <fweimer@redhat.com>
Subject: Re: GCC miscompilation with __seg_fs
Date: Mon, 13 Mar 2023 08:53:26 -0700 [thread overview]
Message-ID: <CA+=Sn1nsb_ZvhMVopB8b99+0aGn64VeTa8zKtSrgJ2LU0+iZDA@mail.gmail.com> (raw)
In-Reply-To: <ZA9FJwpYnneWpvWi@tucnak>
On Mon, Mar 13, 2023 at 8:46 AM Jakub Jelinek via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Mon, Mar 13, 2023 at 06:24:47PM +0300, Sergey Bugaev wrote:
> > Hello,
> >
> > while exploring the generated assembly for an entirely unrelated
> > reason, I found out that GCC eliminates stores through THREAD_SELF
> > when it's declared using __seg_fs. This is easily reproducible outside
> > of glibc; here's a sample reproducer (I've also put it on Godbolt [0]
> > for easy exploration):
>
> Smaller testcase:
> typedef struct
> {
> void *tcb;
> int some_member;
> } tcbhead_t;
>
> void
> assign_through_self (void)
> {
> (*(tcbhead_t * __seg_fs *) __builtin_offsetof (tcbhead_t, tcb))->some_member = 42;
> }
>
> From what I can see, GCC has been DSE removing these since https://gcc.gnu.org/r6-4645
> when __seg_fs support has been introduced.
> One can work-around it using -fno-delete-null-pointer-checks.
> You could also hide the fact that it is based on 0 pointer from the
> compiler...
>
> While GCC has targetm.addr_space.zero_address_valid hook (which AFAIK only
> x86 overrides), we use it only in very few spots right now.
>
> Feel free to file a bug report in GCC bugzilla, but that won't improve
> anything on the already released compilers.
I am 99% sure this is https://gcc.gnu.org/PR102733 or at least related to it.
Thanks,
Andrew Pinski
>
> Jakub
>
next prev parent reply other threads:[~2023-03-13 15:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 15:24 Sergey Bugaev
2023-03-13 15:45 ` Jakub Jelinek
2023-03-13 15:53 ` Andrew Pinski [this message]
2023-03-13 16:13 ` Sergey Bugaev
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='CA+=Sn1nsb_ZvhMVopB8b99+0aGn64VeTa8zKtSrgJ2LU0+iZDA@mail.gmail.com' \
--to=pinskia@gmail.com \
--cc=bugaevc@gmail.com \
--cc=fweimer@redhat.com \
--cc=jakub@redhat.com \
--cc=libc-alpha@sourceware.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).