public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Martin Uecker <uecker@eecs.berkeley.edu>,
	       gcc Mailing List <gcc@gcc.gnu.org>,
	Jeff Law <law@redhat.com>,
	       Jakub Jelinek <jakub@redhat.com>,
	Florian Weimer <fw@deneb.enyo.de>,
	       "Balaji V. Iyer" <balaji.v.iyer@intel.com>
Subject: Re: array bounds, sanitizer, safe programming, and cilk array notation
Date: Sat, 21 Feb 2015 15:41:00 -0000	[thread overview]
Message-ID: <20150221154138.GB18668@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1501262358540.28748@digraph.polyomino.org.uk>

Sorry for late reply.

On Tue, Jan 27, 2015 at 12:07:58AM +0000, Joseph Myers wrote:
> On Mon, 26 Jan 2015, Martin Uecker wrote:
> 
> > extern void bar2(int (*x)[5]);
> 
> > 	int c = 4;
> > 	int y[c];
> 
> > 	bar2(&y);	// not diagnosed (found by asan)
> 
> This is the undefined behavior "If the two array types are used in a 
> context which requires them to be compatible, it is undefined behavior if 
> the two size specifiers evaluate to unequal values." (C11 6.7.6.2#6).  
> Yes, it would make sense for ubsan to detect this.  Generally, most forms 
> of runtime undefined behavior listed in J.2 should have ubsan detection 
> unless hard to detect / detected by some other sanitizer such as asan.
 
I have created a table to that effect some time ago:
http://people.redhat.com/mpolacek/www/analyzability.html
Obviously the question marks should be replaced by a -fsanitize=
option that detects a particular UB.  Or say that a particular UB is a
compile-time error (e.g. "declaring a function at block scope with an explicit
storage-class specifier other than extern").

I don't know what to do with the UBs on the library side - those 7.* ones.

> Does adding new forms of sanitization require upstream libsanitizer 
> changes as well or can arbitrary ubsan checks be added without needing 
> libsanitizer changes?

I think we also need libubsan changes.  But it is usually just about
printing an error message along with some values - nothing terribly
complex.

	Marek

  reply	other threads:[~2015-02-21 15:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 19:54 Martin Uecker
2015-01-27  0:08 ` Joseph Myers
2015-02-21 15:41   ` Marek Polacek [this message]
2015-02-23 17:53     ` Joseph Myers
2015-02-21 15:21 ` Marek Polacek
2015-02-22  0:41   ` Martin Uecker
2015-02-24  1:46     ` questionable checks for flexible array members in c-ubsan.c and tree-vrp.c (was: Re: array bounds, sanitizer, safe programming, and cilk array notation) Martin Uecker

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=20150221154138.GB18668@redhat.com \
    --to=polacek@redhat.com \
    --cc=balaji.v.iyer@intel.com \
    --cc=fw@deneb.enyo.de \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=law@redhat.com \
    --cc=uecker@eecs.berkeley.edu \
    /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).