From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25229 invoked by alias); 13 Dec 2012 07:44:44 -0000 Received: (qmail 25217 invoked by uid 22791); 13 Dec 2012 07:44:42 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_KC,TW_LV X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Dec 2012 07:44:34 +0000 Received: by mail-lb0-f175.google.com with SMTP id gg13so1454324lbb.20 for ; Wed, 12 Dec 2012 23:44:32 -0800 (PST) Received: by 10.152.45.229 with SMTP id q5mr519073lam.34.1355384672785; Wed, 12 Dec 2012 23:44:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.8.132 with HTTP; Wed, 12 Dec 2012 23:44:12 -0800 (PST) In-Reply-To: <20121212213013.GH2315@tucnak.redhat.com> References: <20121128101420.GG2315@tucnak.redhat.com> <20121203110018.GR2315@tucnak.redhat.com> <20121205122906.GO2315@tucnak.redhat.com> <87ehivq8ce.fsf@redhat.com> <20121212213013.GH2315@tucnak.redhat.com> From: Konstantin Serebryany Date: Thu, 13 Dec 2012 07:44:00 -0000 Message-ID: Subject: Re: [PATCH] asan unit tests from llvm lit-test incremental changes To: Jakub Jelinek Cc: Dodji Seketeli , Wei Mi , Mike Stump , GCC Patches , David Li , Diego Novillo , Kostya Serebryany , Dodji Seketeli , Alexander Potapenko , Evgeniy Stepanov , Alexey Samsonov , Dmitry Vyukov Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00886.txt.bz2 On Thu, Dec 13, 2012 at 1:30 AM, Jakub Jelinek 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 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