public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/111736] Address sanitizer is not compatible with named address spaces
Date: Thu, 21 Mar 2024 08:46:31 +0000	[thread overview]
Message-ID: <bug-111736-4-PM5mkWH8Wu@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111736-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to rguenther@suse.de from comment #17)
> On Thu, 21 Mar 2024, ubizjak at gmail dot com wrote:
> 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111736
> > 
> > --- Comment #16 from Uro? Bizjak <ubizjak at gmail dot com> ---
> > (In reply to Richard Biener from comment #13)
> > > The original testcase is fixed, appearantly slapping 'extern' on the int
> > > makes it not effective.
> > > 
> > > Possibly better amend the
> > > 
> > >   if (VAR_P (inner) && DECL_HARD_REGISTER (inner))
> > >     return;
> > > 
> > > check though.  As indicated my fix fixed only VAR_DECL cases, there's
> > > still pointer-based accesses (MEM_REF) to consider.  So possibly even
> > > the following is necessary
> > 
> > I must admit that to create the patch from Comment #11 I just mindlessly
> > searched for DECL_THREAD_LOCAL_P in asan.cc and amended the location with
> > ADDR_SPACE_GENERIC_P check.
> 
> It might be that the DECL_THREAD_LOCAL_P handling is similarly broken
> in that
> 
> int foo (int *p)
> {
>   return *p;
> }

No, that is not broken.  __thread/thread_local is something that applies solely
to variables.  If you take address of a TLS variable, the result is a normal
address space pointer even if TLS uses separate address spaces.  Pointer to TLS
var is e.g. on x86-64 load from %gs:0 with offset added to it, while load/store
of a TLS var is load/store from %gs:offset.
So, we actually wouldn't need to punt on DECL_THREAD_LOCAL_P variables, we can
just check their addresses.
We actually don't insert red zones in between the TLS var, so doing it wouldn't
make significant sense.

  parent reply	other threads:[~2024-03-21  8:46 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 11:53 [Bug sanitizer/111736] New: " ubizjak at gmail dot com
2023-10-09 12:31 ` [Bug sanitizer/111736] " rguenth at gcc dot gnu.org
2023-10-09 13:27 ` amonakov at gcc dot gnu.org
2023-10-09 16:27 ` amonakov at gcc dot gnu.org
2023-12-05 13:05 ` rguenth at gcc dot gnu.org
2023-12-05 14:11 ` cvs-commit at gcc dot gnu.org
2023-12-05 14:12 ` rguenth at gcc dot gnu.org
2023-12-19  9:29 ` ubizjak at gmail dot com
2023-12-19 10:06 ` rguenth at gcc dot gnu.org
2023-12-19 11:04 ` cvs-commit at gcc dot gnu.org
2023-12-29  9:42 ` ubizjak at gmail dot com
2024-03-20 20:04 ` ubizjak at gmail dot com
2024-03-20 21:45 ` ubizjak at gmail dot com
2024-03-21  6:44 ` ubizjak at gmail dot com
2024-03-21  7:24 ` rguenth at gcc dot gnu.org
2024-03-21  7:26 ` rguenth at gcc dot gnu.org
2024-03-21  7:45 ` rguenth at gcc dot gnu.org
2024-03-21  8:04 ` ubizjak at gmail dot com
2024-03-21  8:35 ` rguenther at suse dot de
2024-03-21  8:46 ` jakub at gcc dot gnu.org [this message]
2024-03-21  9:18 ` ubizjak at gmail dot com
2024-03-21  9:26 ` jakub at gcc dot gnu.org
2024-03-21  9:41 ` jakub at gcc dot gnu.org
2024-03-21  9:49 ` cvs-commit at gcc dot gnu.org
2024-03-21 11:49 ` cvs-commit at gcc dot gnu.org
2024-03-21 12:56 ` jakub at gcc dot gnu.org
2024-03-22  8:25 ` cvs-commit at gcc dot gnu.org
2024-03-25  9:13 ` ubizjak at gmail dot com
2024-03-25  9:31 ` jakub at gcc dot gnu.org
2024-03-25  9:45 ` jakub at gcc dot gnu.org
2024-03-25 10:20 ` ubizjak at gmail dot com
2024-03-26 10:13 ` cvs-commit at gcc dot gnu.org
2024-03-30  3:55 ` cvs-commit at gcc dot gnu.org
2024-03-30  3:55 ` cvs-commit at gcc dot gnu.org
2024-04-23 17:09 ` cvs-commit at gcc dot gnu.org
2024-04-23 17:09 ` cvs-commit at gcc dot gnu.org
2024-04-23 17:09 ` cvs-commit at gcc dot gnu.org
2024-04-23 17:09 ` cvs-commit at gcc dot gnu.org
2024-04-24 14:39 ` cvs-commit at gcc dot gnu.org
2024-04-24 14:39 ` cvs-commit at gcc dot gnu.org
2024-04-24 14:39 ` cvs-commit at gcc dot gnu.org
2024-04-24 14:40 ` cvs-commit at gcc dot gnu.org
2024-04-24 14:41 ` ubizjak at gmail dot com
2024-05-20 19:53 ` pchelkin at ispras dot ru
2024-05-20 19:56 ` pchelkin at ispras dot ru
2024-05-20 19:57 ` pchelkin at ispras dot ru
2024-05-21  8:19 ` ubizjak at gmail dot com
2024-05-21  9:01 ` ubizjak at gmail dot com
2024-05-21  9:03 ` ubizjak at gmail dot com
2024-05-21  9:18 ` rguenth at gcc dot gnu.org
2024-05-21  9:20 ` ubizjak at gmail dot com
2024-05-21  9:55 ` ubizjak at gmail dot com

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-111736-4-PM5mkWH8Wu@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).