[PATCH] D31684: [sanitizer] Fix various issues reported by Clang Static Analyzer [NFC]

Dmitry Vyukov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 05:21:41 PDT 2017


dvyukov added inline comments.


================
Comment at: lib/asan/asan_descriptions.cc:455
   data.kind = kAddressKindWild;
-  addr = 0;
+  data.addr = 0;
 }
----------------
This is funny.
The code is incorrect. Your fix is incorrect. And we almost printed a wild address on wild address access. Still it worked correctly. The bug was masked by the fact that GetGlobalAddressInformation initializes first field with address when it must not, and the field is magically collocated with the addr field. So it all kinda worked in the end.

This needs to be:

    data.addr = addr;


================
Comment at: lib/tsan/rtl/tsan_stack_trace.cc:41
+  uptr new_size = cnt + !!extra_top_pc;
+  CHECK(new_size);
+  ResizeBuffer(new_size);
----------------
What's wrong with new_size=0? ResizeBuffer works for size=0, and in fact we call ResizeBuffer(0) in dtor.


================
Comment at: lib/tsan/rtl/tsan_sync.cc:82
 bool MetaMap::FreeRange(Processor *proc, uptr p, uptr sz) {
+  CHECK(proc);
   bool has_something = false;
----------------
Is it the only potential nullptr-deref warning in sanitizer code? There are usually tons of them. So I am confused, is it really so special place? why?


Repository:
  rL LLVM

https://reviews.llvm.org/D31684





More information about the llvm-commits mailing list