public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: binutils@sourceware.org
Subject: Re: x86: generate template sets data at build time
Date: Wed, 14 Dec 2022 18:49:52 +1030	[thread overview]
Message-ID: <Y5mHKKyU2OgA+y8x@squeak.grove.modra.org> (raw)
In-Reply-To: <f38a3591-3f6e-eba8-bd47-e50fc3679309@suse.com>

On Wed, Dec 14, 2022 at 08:40:37AM +0100, Jan Beulich wrote:
> On 14.12.2022 06:14, Alan Modra wrote:
> >> +    /* Type checks to compensate for the conversion through void * which
> >> +       occurs during hash table insertion / lookup.  */
> >> +    (void)(sets == &current_templates->start);
> >> +    (void)(end == &current_templates->end);
> > 
> > This results in asan complaining about "member access within null
> > pointer of type 'const templates'".
> 
> Interesting. How can it know that current_templates is still NULL?

It is instrumented and hits the error at runtime.

> (I guess one can't expect it to realize that with the cast to void
> this doesn't really stand a chance of exhibiting UB; technically
> the compiler _may_ generate code for this nevertheless, and that
> code _may_ do anything due to it being UB.) It's also not clear to
> me what to do to work around the issue: Assign to current_templates
> instead, followed by assigning back NULL after the checks? (This
> would feel like clutter to me.) Are there other "standard" ways of
> working around such border line asan complaints?

Yes, check for NULL before doing the operation.  In this case I'm
inclined to just delete the type checking.

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2022-12-14  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14  5:14 Alan Modra
2022-12-14  7:40 ` Jan Beulich
2022-12-14  8:19   ` Alan Modra [this message]
2022-12-14  8:25     ` Jan Beulich
2022-12-14  8:27     ` Alan Modra
2022-12-14  8:57   ` Andreas Schwab

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=Y5mHKKyU2OgA+y8x@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    /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).