[compiler-rt] r209013 - Exclude several ASan tests from test suite if we're using GCC

Alexey Samsonov samsonov at google.com
Fri May 16 15:49:50 PDT 2014


On Fri, May 16, 2014 at 2:39 PM, Greg Fitzgerald <garious at gmail.com> wrote:

> I'm segfaulting on the dereference of 'shadow_address' in the code
> below. I see there's no special case for __arm__ when setting

SHADOW_OFFSET.  How do we choose this number?
>

Well, we choose this number in such a way that we can mmap the whole shadow
(i.e. it won't
intersect with user mappings). For example, see "Default Linux/i386 mapping
on x86_64 machine"
in asan_mapping.h - we assume that we can mmap LowShadow, ShadowGap and
HighShadow.

If you get shadow_addr as MEM_TO_SHADOW(a) and crash when you dereference
it, it's possible
that you hit the protected shadow gap, that is "a" itself was in shadow.
This shouldn't happen
unless there's a bug somewhere, or you do smth. strange like instrumenting
ASan runtime itself.


>
>
> static inline bool AddressIsPoisoned(uptr a) {
>   PROFILE_ASAN_MAPPING();
>   const uptr kAccessSize = 1;
>   u8 *shadow_address = (u8*)MEM_TO_SHADOW(a);
>   s8 shadow_value = *shadow_address;
>   if (shadow_value) {
>     u8 last_accessed_byte = (a & (SHADOW_GRANULARITY - 1))
>                                  + kAccessSize - 1;
>     return (last_accessed_byte >= shadow_value);
>   }
>   return false;
> }
>
> Thanks,
> Greg
>
> On Fri, May 16, 2014 at 2:31 PM, Greg Fitzgerald <garious at gmail.com>
> wrote:
> > I see, thanks.  Seems I'm looking at a different issue on clang +
> qemu-arm.
> >
> > -Greg
> >
> >
> > On Fri, May 16, 2014 at 2:28 PM, Alexey Samsonov <samsonov at google.com>
> wrote:
> >> On Fri, May 16, 2014 at 2:23 PM, Greg Fitzgerald <garious at gmail.com>
> wrote:
> >>>
> >>> Cool, I was just looking at these.  Do you know what's wrong with GCC
> >>> here?
> >>
> >>
> >> Well, GCC-ASan doesn't support certain sanitizer compile flags. Also,
> >> GCC driver doesn't do the right thing for lines like:
> >>   gcc -x c++ a.cc b.so
> >> (it treats b.so as a source file).
> >>
> >>>
> >>>
> >>> By the way, if you're planning on making this test suite usable with
> >>> GCC, maybe call that feature "Clang-compiled-runtime" to avoid any
> >>> confusion?
> >>
> >>
> >> Nope, it doesn't matter which compiler was used to build the runtime,
> this
> >> feature
> >> is used to distinguish between the compiler/toolchain used to run the
> tests.
> >>
> >> With this change, I'm able to run test-suite for GCC-ASan:
> >>
> https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerTestSuite
> >>
> >>>
> >>>
> >>> -Greg
> >>>
> >>>
> >>> On Fri, May 16, 2014 at 1:12 PM, Alexey Samsonov <samsonov at google.com>
> >>> wrote:
> >>> > Author: samsonov
> >>> > Date: Fri May 16 15:12:27 2014
> >>> > New Revision: 209013
> >>> >
> >>> > URL: http://llvm.org/viewvc/llvm-project?rev=209013&view=rev
> >>> > Log:
> >>> > Exclude several ASan tests from test suite if we're using GCC
> >>> >
> >>> > Modified:
> >>> >     compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc
> >>> >     compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc
> >>> >     compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc
> >>> >     compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc
> >>> >     compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc
> >>> >     compiler-rt/trunk/test/lit.common.cfg
> >>> >
> >>> > Modified:
> >>> > compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc?rev=209013&r1=209012&r2=209013&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc
> >>> > (original)
> >>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc
> Fri
> >>> > May 16 15:12:27 2014
> >>> > @@ -9,7 +9,8 @@
> >>> >  // RUN: %clangxx_asan %t.o %t.so -Wl,-R. -o %t
> >>> >  // RUN: ASAN_OPTIONS=verbosity=1 %run %t 2>&1 | FileCheck %s
> >>> >
> >>> > -// REQUIRES: x86_64-supported-target, asan-64-bits
> >>> > +// GNU driver doesn't handle .so files properly.
> >>> > +// REQUIRES: x86_64-supported-target, asan-64-bits, Clang
> >>> >  #if BUILD_SO
> >>> >  int G;
> >>> >  int *getG() {
> >>> >
> >>> > Modified:
> compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc?rev=209013&r1=209012&r2=209013&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc
> >>> > (original)
> >>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc Fri
> >>> > May 16 15:12:27 2014
> >>> > @@ -4,6 +4,9 @@
> >>> >  // RUN: %clangxx_asan -O2 %s -o %t && \
> >>> >  // RUN:   not %run %t 2>&1 | FileCheck %s
> >>> >
> >>> > +// FIXME: Fix this test under GCC.
> >>> > +// REQUIRES: Clang
> >>> > +
> >>> >  #include <stdio.h>
> >>> >  #include <string.h>
> >>> >  #include <stdlib.h>
> >>> >
> >>> > Modified:
> compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc?rev=209013&r1=209012&r2=209013&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc
> >>> > (original)
> >>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc Fri
> May
> >>> > 16 15:12:27 2014
> >>> > @@ -11,6 +11,9 @@
> >>> >  // RUN: ASAN_OPTIONS=detect_odr_violation=1     %run %t 2>&1 |
> >>> > FileCheck %s --check-prefix=DISABLED
> >>> >  // RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t 2>&1 |
> >>> > FileCheck %s
> >>> >
> >>> > +// GNU driver doesn't handle .so files properly.
> >>> > +// REQUIRES: Clang
> >>> > +
> >>> >  #ifndef SZ
> >>> >  # define SZ 4
> >>> >  #endif
> >>> >
> >>> > Modified: compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc?rev=209013&r1=209012&r2=209013&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc
> >>> > (original)
> >>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc Fri
> May
> >>> > 16 15:12:27 2014
> >>> > @@ -2,6 +2,9 @@
> >>> >  // RUN: %clangxx_asan -DFUNC=main %s         -o %t    -Wl,-R. %t.so
> >>> >  // RUN: %run %t
> >>> >
> >>> > +// GNU driver doesn't handle .so files properly.
> >>> > +// REQUIRES: Clang
> >>> > +
> >>> >  // This test ensures that we call __asan_init early enough.
> >>> >  // We build a shared library w/o asan instrumentation
> >>> >  // and the binary with asan instrumentation.
> >>> >
> >>> > Modified: compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc?rev=209013&r1=209012&r2=209013&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc (original)
> >>> > +++ compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc Fri May 16
> >>> > 15:12:27 2014
> >>> > @@ -3,6 +3,10 @@
> >>> >  // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck
> %s
> >>> >  // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck
> %s
> >>> >  // RUN: ASAN_OPTIONS=print_stats=1 not %run %t 2>&1 | FileCheck %s
> >>> > +
> >>> > +// FIXME: Fix this test under GCC.
> >>> > +// REQUIRES: Clang
> >>> > +
> >>> >  #include <stdlib.h>
> >>> >  #include <string.h>
> >>> >  int main(int argc, char **argv) {
> >>> >
> >>> > Modified: compiler-rt/trunk/test/lit.common.cfg
> >>> > URL:
> >>> >
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=209013&r1=209012&r2=209013&view=diff
> >>> >
> >>> >
> ==============================================================================
> >>> > --- compiler-rt/trunk/test/lit.common.cfg (original)
> >>> > +++ compiler-rt/trunk/test/lit.common.cfg Fri May 16 15:12:27 2014
> >>> > @@ -28,6 +28,8 @@ elif compiler_id == 'GNU':
> >>> >    config.cxx_mode_flags = ["-x c++"]
> >>> >  else:
> >>> >    lit_config.fatal("Unsupported compiler id: %r" % compiler_id)
> >>> > +# Add compiler ID to the list of available features.
> >>> > +config.available_features.add(compiler_id)
> >>> >
> >>> >  # Clear some environment variables that might affect Clang.
> >>> >  possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
> >>> >
> >>> >
> >>> > _______________________________________________
> >>> > llvm-commits mailing list
> >>> > llvm-commits at cs.uiuc.edu
> >>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >>
> >>
> >>
> >>
> >> --
> >> Alexey Samsonov, Mountain View, CA
>



-- 
Alexey Samsonov, Mountain View, CA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140516/b1899283/attachment.html>


More information about the llvm-commits mailing list