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

--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #19)
> (In reply to Uroš Bizjak from comment #16)
> > (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.
> > 
> > However, ASAN should back off from annotating *any* gs: prefixed address. 
> > 
> > I'll test your patch from Comment #13 ASAP.
> 
> Weee, it works!
> 
> Decompressing Linux... Parsing ELF... Performing relocations... done.
> Booting the kernel (entry_offset: 0x0000000000000000).
> [    0.000000] Linux version 6.8.0-11485-ge1826833c3a9 (uros@localhost)
> (xgcc (GCC) 14.0.1 20240321 (experimental) [master r14-9588-g415091f0909],
> GNU ld version 2.40-14.fc39) #1 SMP PREEMPT_DYNAMIC Thu Mar 21 09:44:30 CET
> 2024
> ...
> 
> I have used slightly different patch:
> 
> --cut here--
> diff --git a/gcc/asan.cc b/gcc/asan.cc
> index cfe83106460..026d079a4a1 100644
> --- a/gcc/asan.cc
> +++ b/gcc/asan.cc
> @@ -2755,6 +2755,9 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
>    if (VAR_P (inner) && DECL_HARD_REGISTER (inner))
>      return;
>  
> +  if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner))))
> +    return;
> +

Agreed, this looks better.

Though, talking about address spaces, guess we also need to change ubsan.cc,
so that for targetm.addr_space.zero_address_valid (as) case it actually doesn't
try to
verify the pointers aren't NULL (it still should check alignment).

Reply via email to