<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 16, 2014 at 2:39 PM, Greg Fitzgerald <span dir="ltr"><<a href="mailto:garious@gmail.com" target="_blank">garious@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I'm segfaulting on the dereference of 'shadow_address' in the code<br>

below. I see there's no special case for __arm__ when setting</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

SHADOW_OFFSET.  How do we choose this number?<br></blockquote><div><br></div><div>Well, we choose this number in such a way that we can mmap the whole shadow (i.e. it won't</div><div>intersect with user mappings). For example, see "Default Linux/i386 mapping on x86_64 machine"</div>
<div>in asan_mapping.h - we assume that we can mmap LowShadow, ShadowGap and HighShadow.</div><div><br></div><div>If you get shadow_addr as MEM_TO_SHADOW(a) and crash when you dereference it, it's possible</div><div>that you hit the protected shadow gap, that is "a" itself was in shadow. This shouldn't happen</div>
<div>unless there's a bug somewhere, or you do smth. strange like instrumenting ASan runtime itself.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br>
static inline bool AddressIsPoisoned(uptr a) {<br>
  PROFILE_ASAN_MAPPING();<br>
  const uptr kAccessSize = 1;<br>
  u8 *shadow_address = (u8*)MEM_TO_SHADOW(a);<br>
  s8 shadow_value = *shadow_address;<br>
  if (shadow_value) {<br>
    u8 last_accessed_byte = (a & (SHADOW_GRANULARITY - 1))<br>
                                 + kAccessSize - 1;<br>
    return (last_accessed_byte >= shadow_value);<br>
  }<br>
  return false;<br>
}<br>
<br>
Thanks,<br>
Greg<br>
<div class=""><div class="h5"><br>
On Fri, May 16, 2014 at 2:31 PM, Greg Fitzgerald <<a href="mailto:garious@gmail.com">garious@gmail.com</a>> wrote:<br>
> I see, thanks.  Seems I'm looking at a different issue on clang + qemu-arm.<br>
><br>
> -Greg<br>
><br>
><br>
> On Fri, May 16, 2014 at 2:28 PM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
>> On Fri, May 16, 2014 at 2:23 PM, Greg Fitzgerald <<a href="mailto:garious@gmail.com">garious@gmail.com</a>> wrote:<br>
>>><br>
>>> Cool, I was just looking at these.  Do you know what's wrong with GCC<br>
>>> here?<br>
>><br>
>><br>
>> Well, GCC-ASan doesn't support certain sanitizer compile flags. Also,<br>
>> GCC driver doesn't do the right thing for lines like:<br>
>>   gcc -x c++ a.cc b.so<br>
>> (it treats b.so as a source file).<br>
>><br>
>>><br>
>>><br>
>>> By the way, if you're planning on making this test suite usable with<br>
>>> GCC, maybe call that feature "Clang-compiled-runtime" to avoid any<br>
>>> confusion?<br>
>><br>
>><br>
>> Nope, it doesn't matter which compiler was used to build the runtime, this<br>
>> feature<br>
>> is used to distinguish between the compiler/toolchain used to run the tests.<br>
>><br>
>> With this change, I'm able to run test-suite for GCC-ASan:<br>
>> <a href="https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerTestSuite" target="_blank">https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerTestSuite</a><br>
>><br>
>>><br>
>>><br>
>>> -Greg<br>
>>><br>
>>><br>
>>> On Fri, May 16, 2014 at 1:12 PM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>><br>
>>> wrote:<br>
>>> > Author: samsonov<br>
>>> > Date: Fri May 16 15:12:27 2014<br>
>>> > New Revision: 209013<br>
>>> ><br>
>>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=209013&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=209013&view=rev</a><br>
>>> > Log:<br>
>>> > Exclude several ASan tests from test suite if we're using GCC<br>
>>> ><br>
>>> > Modified:<br>
>>> >     compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc<br>
>>> >     compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc<br>
>>> >     compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc<br>
>>> >     compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc<br>
>>> >     compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc<br>
>>> >     compiler-rt/trunk/test/lit.common.cfg<br>
>>> ><br>
>>> > Modified:<br>
>>> > compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc<br>
>>> > URL:<br>
>>> > <a href="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" target="_blank">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</a><br>

>>> ><br>
>>> > ==============================================================================<br>
>>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc<br>
>>> > (original)<br>
>>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/asan_prelink_test.cc Fri<br>
>>> > May 16 15:12:27 2014<br>
>>> > @@ -9,7 +9,8 @@<br>
>>> >  // RUN: %clangxx_asan %t.o %t.so -Wl,-R. -o %t<br>
>>> >  // RUN: ASAN_OPTIONS=verbosity=1 %run %t 2>&1 | FileCheck %s<br>
>>> ><br>
>>> > -// REQUIRES: x86_64-supported-target, asan-64-bits<br>
>>> > +// GNU driver doesn't handle .so files properly.<br>
>>> > +// REQUIRES: x86_64-supported-target, asan-64-bits, Clang<br>
>>> >  #if BUILD_SO<br>
>>> >  int G;<br>
>>> >  int *getG() {<br>
>>> ><br>
>>> > Modified: compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc<br>
>>> > URL:<br>
>>> > <a href="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" target="_blank">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</a><br>

>>> ><br>
>>> > ==============================================================================<br>
>>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc<br>
>>> > (original)<br>
>>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/heavy_uar_test.cc Fri<br>
>>> > May 16 15:12:27 2014<br>
>>> > @@ -4,6 +4,9 @@<br>
>>> >  // RUN: %clangxx_asan -O2 %s -o %t && \<br>
>>> >  // RUN:   not %run %t 2>&1 | FileCheck %s<br>
>>> ><br>
>>> > +// FIXME: Fix this test under GCC.<br>
>>> > +// REQUIRES: Clang<br>
>>> > +<br>
>>> >  #include <stdio.h><br>
>>> >  #include <string.h><br>
>>> >  #include <stdlib.h><br>
>>> ><br>
>>> > Modified: compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc?rev=209013&r1=209012&r2=209013&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc?rev=209013&r1=209012&r2=209013&view=diff</a><br>

>>> ><br>
>>> > ==============================================================================<br>
>>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc<br>
>>> > (original)<br>
>>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc Fri May<br>
>>> > 16 15:12:27 2014<br>
>>> > @@ -11,6 +11,9 @@<br>
>>> >  // RUN: ASAN_OPTIONS=detect_odr_violation=1     %run %t 2>&1 |<br>
>>> > FileCheck %s --check-prefix=DISABLED<br>
>>> >  // RUN: ASAN_OPTIONS=detect_odr_violation=2 not %run %t 2>&1 |<br>
>>> > FileCheck %s<br>
>>> ><br>
>>> > +// GNU driver doesn't handle .so files properly.<br>
>>> > +// REQUIRES: Clang<br>
>>> > +<br>
>>> >  #ifndef SZ<br>
>>> >  # define SZ 4<br>
>>> >  #endif<br>
>>> ><br>
>>> > Modified: compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc?rev=209013&r1=209012&r2=209013&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc?rev=209013&r1=209012&r2=209013&view=diff</a><br>

>>> ><br>
>>> > ==============================================================================<br>
>>> > --- compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc<br>
>>> > (original)<br>
>>> > +++ compiler-rt/trunk/test/asan/TestCases/Linux/preinit_test.cc Fri May<br>
>>> > 16 15:12:27 2014<br>
>>> > @@ -2,6 +2,9 @@<br>
>>> >  // RUN: %clangxx_asan -DFUNC=main %s         -o %t    -Wl,-R. %t.so<br>
>>> >  // RUN: %run %t<br>
>>> ><br>
>>> > +// GNU driver doesn't handle .so files properly.<br>
>>> > +// REQUIRES: Clang<br>
>>> > +<br>
>>> >  // This test ensures that we call __asan_init early enough.<br>
>>> >  // We build a shared library w/o asan instrumentation<br>
>>> >  // and the binary with asan instrumentation.<br>
>>> ><br>
>>> > Modified: compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc?rev=209013&r1=209012&r2=209013&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc?rev=209013&r1=209012&r2=209013&view=diff</a><br>

>>> ><br>
>>> > ==============================================================================<br>
>>> > --- compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc (original)<br>
>>> > +++ compiler-rt/trunk/test/asan/TestCases/heap-overflow.cc Fri May 16<br>
>>> > 15:12:27 2014<br>
>>> > @@ -3,6 +3,10 @@<br>
>>> >  // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s<br>
>>> >  // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s<br>
>>> >  // RUN: ASAN_OPTIONS=print_stats=1 not %run %t 2>&1 | FileCheck %s<br>
>>> > +<br>
>>> > +// FIXME: Fix this test under GCC.<br>
>>> > +// REQUIRES: Clang<br>
>>> > +<br>
>>> >  #include <stdlib.h><br>
>>> >  #include <string.h><br>
>>> >  int main(int argc, char **argv) {<br>
>>> ><br>
>>> > Modified: compiler-rt/trunk/test/lit.common.cfg<br>
>>> > URL:<br>
>>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=209013&r1=209012&r2=209013&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=209013&r1=209012&r2=209013&view=diff</a><br>

>>> ><br>
>>> > ==============================================================================<br>
>>> > --- compiler-rt/trunk/test/lit.common.cfg (original)<br>
>>> > +++ compiler-rt/trunk/test/lit.common.cfg Fri May 16 15:12:27 2014<br>
>>> > @@ -28,6 +28,8 @@ elif compiler_id == 'GNU':<br>
>>> >    config.cxx_mode_flags = ["-x c++"]<br>
>>> >  else:<br>
>>> >    lit_config.fatal("Unsupported compiler id: %r" % compiler_id)<br>
>>> > +# Add compiler ID to the list of available features.<br>
>>> > +config.available_features.add(compiler_id)<br>
>>> ><br>
>>> >  # Clear some environment variables that might affect Clang.<br>
>>> >  possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',<br>
>>> ><br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > llvm-commits mailing list<br>
>>> > <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>>> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Alexey Samsonov, Mountain View, CA<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Alexey Samsonov, Mountain View, CA</div></div>
</div></div>