This is the mail archive of the
mailing list for the GCC project.
Re: array bounds, sanitizer, safe programming, and cilk array notation
- From: Marek Polacek <polacek at redhat dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: Martin Uecker <uecker at eecs dot berkeley dot edu>, gcc Mailing List <gcc at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, Florian Weimer <fw at deneb dot enyo dot de>, "Balaji V. Iyer" <balaji dot v dot iyer at intel dot com>
- Date: Sat, 21 Feb 2015 16:41:38 +0100
- Subject: Re: array bounds, sanitizer, safe programming, and cilk array notation
- Authentication-results: sourceware.org; auth=none
- References: <20150126115359 dot 295659da at lemur> <alpine dot DEB dot 2 dot 10 dot 1501262358540 dot 28748 at digraph dot polyomino dot org dot 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));
> > 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 188.8.131.52#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:
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