tsan: better error message for OOM
authorDmitry Vyukov <dvyukov@google.com>
Thu, 22 Nov 2012 08:42:01 +0000 (08:42 +0000)
committerDmitry Vyukov <dvyukov@google.com>
Thu, 22 Nov 2012 08:42:01 +0000 (08:42 +0000)
llvm-svn: 168491

compiler-rt/lib/sanitizer_common/sanitizer_allocator64.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator64_test.cc

index d0341ad..a537ff0 100644 (file)
@@ -277,7 +277,12 @@ class SizeClassAllocator64 {
     } while (idx < end_idx);
     region->allocated_user += idx - beg_idx;
     region->allocated_meta += i * kMetadataSize;
-    CHECK_LT(region->allocated_user + region->allocated_meta, kRegionSize);
+    if (region->allocated_user + region->allocated_meta > kRegionSize) {
+      Printf("Out of memory. Dying.\n");
+      Printf("The process has exhausted %zuMB for size class %zu.\n",
+          kRegionSize / 1024 / 1024, size);
+      Die();
+    }
   }
 
   void *AllocateBySizeClass(uptr class_id) {
index bf76848..2d97d3a 100644 (file)
@@ -136,7 +136,7 @@ void FailInAssertionOnOOM() {
 
 TEST(SanitizerCommon, SizeClassAllocator64Overflow) {
   EXPECT_DEATH(FailInAssertionOnOOM(),
-               "allocated_user.*allocated_meta.*kRegionSize");
+               "Out of memory");
 }
 
 TEST(SanitizerCommon, LargeMmapAllocator) {