[llvm-commits] [compiler-rt] r150398 - in /compiler-rt/trunk/lib/asan: asan_internal.h asan_linux.cc asan_mac.cc asan_rtl.cc asan_win.cc

Alexander Potapenko glider at google.com
Tue Feb 14 01:10:56 PST 2012


David,

I hope this was fixed by r150400
May I ask whether you're specifically building ASan or just noticed
this because it broke compiler-rt?

On Mon, Feb 13, 2012 at 9:30 PM, David Dean <david_dean at apple.com> wrote:
> Alexander,
>        I think you missed something in this commit:
>
>  COMPILE:   clang_darwin/asan_osx/i386: /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin10-gcc42-RA/llvm/projects/compiler-rt/lib/asan/asan_thread.cc
>
> /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin10-gcc42-RA/llvm/projects/compiler-rt/lib/asan/asan_mac.cc:106:31: error: use of undeclared identifier 'kLowShadowBeg'
>                              kLowShadowBeg - kMmapGranularity,
>                              ^
>
>
> On 13 Feb 2012, at 9:09 AM, Alexander Potapenko wrote:
>
>> Author: glider
>> Date: Mon Feb 13 11:09:40 2012
>> New Revision: 150398
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=150398&view=rev
>> Log:
>> Move the non-trivial implementation of AsanShadowRangeIsAvailable to asan_mac.cc
>> to avoid crashes on Linux and Win.
>>
>> Modified:
>>    compiler-rt/trunk/lib/asan/asan_internal.h
>>    compiler-rt/trunk/lib/asan/asan_linux.cc
>>    compiler-rt/trunk/lib/asan/asan_mac.cc
>>    compiler-rt/trunk/lib/asan/asan_rtl.cc
>>    compiler-rt/trunk/lib/asan/asan_win.cc
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_internal.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=150398&r1=150397&r2=150398&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_internal.h (original)
>> +++ compiler-rt/trunk/lib/asan/asan_internal.h Mon Feb 13 11:09:40 2012
>> @@ -125,8 +125,9 @@
>>
>> void OutOfMemoryMessageAndDie(const char *mem_type, size_t size);
>>
>> -// asan_linux.cc / asan_mac.cc
>> +// asan_linux.cc / asan_mac.cc / asan_win.cc
>> void *AsanDoesNotSupportStaticLinkage();
>> +bool AsanShadowRangeIsAvailable();
>> int AsanOpenReadonly(const char* filename);
>> const char *AsanGetEnv(const char *name);
>>
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=150398&r1=150397&r2=150398&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_linux.cc Mon Feb 13 11:09:40 2012
>> @@ -43,6 +43,11 @@
>>   return &_DYNAMIC;  // defined in link.h
>> }
>>
>> +bool AsanShadowRangeIsAvailable() {
>> +  // FIXME: shall we need anything here on Linux?
>> +  return true;
>> +}
>> +
>> void GetPcSpBp(void *context, uintptr_t *pc, uintptr_t *sp, uintptr_t *bp) {
>> #ifdef ANDROID
>>   *pc = *sp = *bp = 0;
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=150398&r1=150397&r2=150398&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_mac.cc Mon Feb 13 11:09:40 2012
>> @@ -76,6 +76,42 @@
>>   return NULL;
>> }
>>
>> +inline bool IntervalsAreSeparate(uintptr_t start1, uintptr_t end1,
>> +                                 uintptr_t start2, uintptr_t end2) {
>> +  CHECK(start1 <= end1);
>> +  CHECK(start2 <= end2);
>> +  if (start1 == start2) {
>> +    return false;
>> +  } else {
>> +    if (start1 < start2) {
>> +      return (end1 < start2);
>> +    } else {
>> +      return (end2 < start1);
>> +    }
>> +  }
>> +  return false;
>> +}
>> +
>> +// FIXME: this is thread-unsafe, but should not cause problems most of the time.
>> +// When the shadow is mapped only a single thread usually exists (plus maybe
>> +// several worker threads on Mac, which aren't expected to map big chunks of
>> +// memory).
>> +bool AsanShadowRangeIsAvailable() {
>> +  AsanProcMaps procmaps;
>> +  uintptr_t start, end;
>> +  bool available = true;
>> +  while (procmaps.Next(&start, &end,
>> +                       /*offset*/NULL, /*filename*/NULL, /*size*/NULL)) {
>> +    if (!IntervalsAreSeparate(start, end,
>> +                              kLowShadowBeg - kMmapGranularity,
>> +                              kHighShadowEnd)) {
>> +      available = false;
>> +      break;
>> +    }
>> +  }
>> +  return available;
>> +}
>> +
>> bool AsanInterceptsSignal(int signum) {
>>   return (signum == SIGSEGV || signum == SIGBUS) && FLAG_handle_segv;
>> }
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=150398&r1=150397&r2=150398&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Mon Feb 13 11:09:40 2012
>> @@ -118,42 +118,6 @@
>>   CHECK(res == (void*)beg && "ReserveShadowMemoryRange failed");
>> }
>>
>> -inline bool IntervalsAreSeparate(uintptr_t start1, uintptr_t end1,
>> -                                 uintptr_t start2, uintptr_t end2) {
>> -  CHECK(start1 <= end1);
>> -  CHECK(start2 <= end2);
>> -  if (start1 == start2) {
>> -    return false;
>> -  } else {
>> -    if (start1 < start2) {
>> -      return (end1 < start2);
>> -    } else {
>> -      return (end2 < start1);
>> -    }
>> -  }
>> -  return false;
>> -}
>> -
>> -// FIXME: this is thread-unsafe, but should not cause problems most of the time.
>> -// When the shadow is mapped only a single thread usually exists (plus maybe
>> -// several worker threads on Mac, which aren't expected to map big chunks of
>> -// memory.
>> -bool AsanShadowRangeIsAvailable() {
>> -  AsanProcMaps procmaps;
>> -  uintptr_t start, end;
>> -  bool available = true;
>> -  while (procmaps.Next(&start, &end,
>> -                       /*offset*/NULL, /*filename*/NULL, /*size*/NULL)) {
>> -    if (!IntervalsAreSeparate(start, end,
>> -                              kLowShadowBeg - kMmapGranularity,
>> -                              kHighShadowEnd)) {
>> -      available = false;
>> -      break;
>> -    }
>> -  }
>> -  return available;
>> -}
>> -
>> // ---------------------- LowLevelAllocator ------------- {{{1
>> void *LowLevelAllocator::Allocate(size_t size) {
>>   CHECK((size & (size - 1)) == 0 && "size must be a power of two");
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_win.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=150398&r1=150397&r2=150398&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_win.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_win.cc Mon Feb 13 11:09:40 2012
>> @@ -223,6 +223,11 @@
>>   return NULL;
>> }
>>
>> +bool AsanShadowRangeIsAvailable() {
>> +  // FIXME: shall we do anything here on Windows?
>> +  return true;
>> +}
>> +
>> int AtomicInc(int *a) {
>>   return InterlockedExchangeAdd((LONG*)a, 1) + 1;
>> }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> -David
>
>



-- 
Alexander Potapenko
Software Engineer
Google Moscow




More information about the llvm-commits mailing list