[PATCH] D19653: [tsan] Return 0 from malloc_size for non-malloc'd pointers

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 05:52:44 PDT 2016


kubabrecka added inline comments.

================
Comment at: lib/tsan/rtl/tsan_mman.cc:167
@@ -166,2 +166,3 @@
   MBlock *b = ctx->metamap.GetBlock((uptr)p);
-  return b ? b->siz : 0;
+  if (!b)
+    return 0;  // Not a valid pointer.
----------------
aizatsky wrote:
> this changes behavior on all platforms, not only Mac, right? Is it intended?
Correct, this changes all platforms.  It is intended, I should have said that in the original description.  At least on Linux, malloc_usable_size also returns non-zero value for a zero-sized allocation, I guess other platforms behave the same.  Running under TSan shouldn't change that to avoid breaking compatibility.


http://reviews.llvm.org/D19653





More information about the llvm-commits mailing list