public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Konstantin Serebryany <konstantin.s.serebryany@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Dodji Seketeli <dodji@redhat.com>, Wei Mi <wmi@google.com>,
	Mike Stump <mikestump@comcast.net>,
		GCC Patches <gcc-patches@gcc.gnu.org>,
	David Li <davidxl@google.com>,
		Diego Novillo <dnovillo@google.com>,
	Kostya Serebryany <kcc@google.com>,
		Dodji Seketeli <dseketel@redhat.com>,
	Alexander Potapenko <glider@google.com>,
		Evgeniy Stepanov <eugenis@google.com>,
	Alexey Samsonov <samsonov@google.com>,
		Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH] asan unit tests from llvm lit-test incremental changes
Date: Thu, 13 Dec 2012 07:44:00 -0000	[thread overview]
Message-ID: <CAGQ9bdzDncOHruvnAk14LCRjfXa2s4=d5nnXHX2+aenuYB0i+Q@mail.gmail.com> (raw)
In-Reply-To: <20121212213013.GH2315@tucnak.redhat.com>

On Thu, Dec 13, 2012 at 1:30 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, Dec 12, 2012 at 10:16:49PM +0100, Dodji Seketeli wrote:
>> Independently of this review, I think it's be interesting to hear
>> Kostya's voice on:
>>
>> Jakub Jelinek <jakub@redhat.com> writes:
>>
>> > 2) In large-func-test-1.C, I had to stop matching the backtrace after
>> > _Znw[jm], because libasan is using the fast but inaccurate backtrace,
>> > and while the tests can be easily tweaked to compile with
>> > -fno-omit-frame-pointer, we definitely can't rely on libstdc++.so to be
>> > built with that option.  Most likely it isn't.

The tests should be built with -fno-omit-frame-pointer and we don't
need that for libstdc++.so.
This is how it works in LLVM.
asan's interceptors are written in such a way that they don't care
if libstdc++.so or the asan run-time have frame pointers.

>>> I repeat that I think
>> > that at least for Linux libasan should use the _Unwind* based backtrace
>> > at least for the fatal functions (__asan_report* etc.),

We are discussing it from time to time.
Sometimes, if e.g. an error happens inside a qsort callback,
the fp-based unwinder fails to unwind through libc, while _Unwind would work.

I was opposed to this sometime ago because _Unwind often produced
buggy stack traces on Ubuntu Lucid (the version we cared about).
I also vaguely remember some problems with _Unwind* depending on
malloc (or maybe that's something else?)
Now we mostly care about Ubuntu Precise and we need to test whether
_Unwind produces good enough results there before switching.

unwinding on malloc/free should keep using the fp-based unwinder, at
least by default.

We'll be tracking the issue in
https://code.google.com/p/address-sanitizer/issues/detail?id=137

>>  and perhaps for
>> > these malloc wrappers like ::operator new, ::operator new[] and their
>> > const std::nothrow_t& variants libasan could intercept them, call
>> > malloc and if that returns NULL, call the original corresponding function
>> > so that it deals with exceptions, new handler etc.

Hmm.. Why's that?
Calling libc's malloc or libstdc++'s operator new in asan run-time is
really a bad idea.
asan's allocator should never return 0 anyway, it should simply crash.
I don't think we want to support new handler at all.

>
> Yeah, I'd appreciate that too.





>
>> and on:
>>
>> > 3) deep-thread-stack-1.C fails for me right now with some libasan assertion,
>> > Kostya, can you please look at that?
>> >   AsanThread *t = asanThreadRegistry().GetCurrent();
>> >   CHECK(t);
>> > where it failed on the CHECK, because t was NULL.  I've skipped the test for
>> > now.
>>
>> [...]
>
> This one is for the testcase solved right now already by the -lasan -lpthread
> linking instead of just -lpthread (and driver adding -lasan afterwards).
> We'll need to think about how to tweak the driver to add -lasan early on the
> command line, before user passed -l* options.
>>
>> > --- gcc/testsuite/g++.dg/asan/deep-tail-call-1.C.jj 2012-12-04 20:24:10.000000000 +0100
>> > +++ gcc/testsuite/g++.dg/asan/deep-tail-call-1.C    2012-12-05 11:01:48.600443834 +0100
>> > @@ -1,21 +1,22 @@
>> > -// { dg-do run }
>> > +// { dg-do run }
>> >  // { dg-options "-fno-omit-frame-pointer -fno-optimize-sibling-calls" }
>> >  // { dg-additional-options "-mno-omit-leaf-frame-pointer" { target { i?86-*-* x86_64-*-* } } }
>> > -// { dg-shouldfail "asan" }
>> > +// { dg-shouldfail "asan" }
>> >
>> >  int global[10];
>> >  void __attribute__((noinline)) call4(int i) { global[i+10]++; }
>> >  void __attribute__((noinline)) call3(int i) { call4(i); }
>> >  void __attribute__((noinline)) call2(int i) { call3(i); }
>> >  void __attribute__((noinline)) call1(int i) { call2(i); }
>> > -int main(int argc, char **argv) {
>> > -  call1(argc);
>> > +volatile int one = 1;
>>
>> Just curious, why do we need this variable to be volatile, especially
>> since the test is compiled without optimization?
>
> asan.exp tests are torture tests, they iterate over several -O* options,
> unless explicitly dg-skip-if skipped.  It could be non-volatile with
> asm volatile ("" : : : "memory");
> or asm volatile ("" : "+m" (one)); or similar too, sure.
> I just don't want to rely on argc being one, and the compiler shouldn't know
> that one is 1 in the test.
>
>> [...]
>>
>> The patch looks OK to me in any case.
>
> Thanks.
>
>         Jakub


--kcc

  reply	other threads:[~2012-12-13  7:44 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28  9:15 [PATCH] asan unit tests from llvm lit-test Wei Mi
2012-11-28 10:10 ` Konstantin Serebryany
2012-11-28 10:25   ` Jakub Jelinek
2012-11-28 10:41     ` Konstantin Serebryany
2012-11-28 11:03       ` Jakub Jelinek
2012-11-28 11:14         ` Konstantin Serebryany
2012-11-29 20:59           ` [PATCH] asan_test.cc from llvm Jakub Jelinek
2012-11-30  9:35             ` Konstantin Serebryany
2012-11-30 10:22               ` Jakub Jelinek
2012-11-30 10:55                 ` Konstantin Serebryany
2012-11-30 14:52                   ` Jakub Jelinek
2012-11-30 16:06                     ` Jakub Jelinek
     [not found]                       ` <CAKOQZ8y70goUL91pQJt_S=8W+Dn5VTZ5oRphvGuFwMMh41mkLg@mail.gmail.com>
2012-11-30 16:34                         ` Jakub Jelinek
2012-12-03  7:07                           ` Konstantin Serebryany
2012-12-03  9:18                             ` Jakub Jelinek
2012-12-03  9:52                               ` Konstantin Serebryany
2012-12-03 11:05                                 ` Jakub Jelinek
2012-12-03 11:42                                   ` Konstantin Serebryany
2012-11-28 11:25         ` [PATCH] asan unit tests from llvm lit-test Jakub Jelinek
2012-11-28 11:39           ` Konstantin Serebryany
2012-11-28 10:14 ` Jakub Jelinek
2012-11-30 21:05   ` Wei Mi
2012-12-03  7:16     ` Konstantin Serebryany
2012-12-03 11:01     ` Jakub Jelinek
2012-12-03 18:33       ` Wei Mi
2012-12-03 18:49         ` Konstantin Serebryany
2012-12-03 19:44         ` Jakub Jelinek
2012-12-03 19:09       ` Mike Stump
2012-12-03 19:37         ` Jakub Jelinek
2012-12-03 19:50           ` Mike Stump
     [not found]             ` <CAN=P9pgjjq66KS2DVkuOSeH2ejQPDcyKhwz5MdKyE3RB64E=xw@mail.gmail.com>
2012-12-04  7:34               ` Jakub Jelinek
2012-12-04 18:01       ` Wei Mi
2012-12-05 12:29         ` [PATCH] asan unit tests from llvm lit-test incremental changes Jakub Jelinek
2012-12-12 21:32           ` Dodji Seketeli
2012-12-12 21:31             ` Jakub Jelinek
2012-12-13  7:44               ` Konstantin Serebryany [this message]
2012-12-13  8:37                 ` Jakub Jelinek
2012-12-13 10:23                   ` Konstantin Serebryany
2012-12-13 15:22                     ` Jakub Jelinek
2012-12-05 23:29         ` [asan] Fix up dg-set-target-env-var Jakub Jelinek
2012-12-06  0:23           ` Mike Stump

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='CAGQ9bdzDncOHruvnAk14LCRjfXa2s4=d5nnXHX2+aenuYB0i+Q@mail.gmail.com' \
    --to=konstantin.s.serebryany@gmail.com \
    --cc=davidxl@google.com \
    --cc=dnovillo@google.com \
    --cc=dodji@redhat.com \
    --cc=dseketel@redhat.com \
    --cc=dvyukov@google.com \
    --cc=eugenis@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=glider@google.com \
    --cc=jakub@redhat.com \
    --cc=kcc@google.com \
    --cc=mikestump@comcast.net \
    --cc=samsonov@google.com \
    --cc=wmi@google.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).