[PATCH] D29786: Use pthreads to manage thread-local storage on darwin for leak sanitizer

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 12:25:47 PST 2017


fjricci added inline comments.


================
Comment at: lib/lsan/lsan_common_mac.cc:35
+  if (ptr == NULL && allocate) {
+    ptr = (int *)malloc(sizeof(0));
+    *ptr = 0;
----------------
kubamracek wrote:
> Oh.  Then use `sizeof(*ptr)`.  It's completely non-obvious what `sizeof(0)` evaluates to (and I doubt it's guaranteed to equal `sizeof(int)`.
> 
> Also, shouldn't this be `InternalAlloc` instead of `malloc`?  But you probably know better than me here.
Yeah, it was tricky to figure out what the convention was here, as either way is pretty rare in the sanitizers. `InternalAlloc` does look more reasonable.


https://reviews.llvm.org/D29786





More information about the llvm-commits mailing list