This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, RFC] Introduce -fsanitize=use-after-scope
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Yury Gribov <y dot gribov at samsung dot com>
- Cc: Martin LiÅka <mliska at suse dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 6 May 2016 14:38:57 +0200
- Subject: Re: [PATCH, RFC] Introduce -fsanitize=use-after-scope
- Authentication-results: sourceware.org; auth=none
- References: <572C7A3E dot 4000905 at suse dot cz> <572C848E dot 9020705 at samsung dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, May 06, 2016 at 02:48:30PM +0300, Yury Gribov wrote:
> >6) As the use-after-scope stuff is already included in libsanitizer, no change is needed for the library
>
> Note that upstream seems to use a different cmdline interface. They don't
> have a dedicated -fsanitize=use-after-scope and instead consider it to be a
> part of -fsanitize=address (disabled by default, enabled via -mllvm
> -asan-use-after-scope=1). I'd suggest to keep this interface (or at least
> discuss with them) and use GCC's --param.
I personally think -fsanitize=use-after-scope (which implies address
sanitization in it) is better, can upstream be convinved not to change it?
> FTR here's the upstream work on this: http://reviews.llvm.org/D19347
>
> >Example:
> >
> >int
> >main (void)
> >{
> > char *ptr;
> > {
> > char my_char[9];
> > ptr = &my_char[0];
> > }
> >
> > *(ptr+9) = 'c';
> >}
Well, this testcase shows not just use after scope, but also out of bound
access. Would be better not to combine it, at least in the majority of
testcases.
Jakub