This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Fix various issues reported by Clang Static Analyzer [NFC]
Needs ReviewPublic

Authored by kubamracek on Apr 4 2017, 4:06 PM.

Details

Summary

There's several issues reported by Clang Static Analyzer: Some dead stores, some potential null-pointer dereferences, and a possible garbage value read. They are all pretty straightforward, so this patch fixes them all at once. NFC.

Diff Detail

Event Timeline

kubamracek created this revision.Apr 4 2017, 4:06 PM
dvyukov added inline comments.Apr 21 2017, 5:21 AM
lib/asan/asan_descriptions.cc
455

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;
lib/tsan/rtl/tsan_stack_trace.cc
41

What's wrong with new_size=0? ResizeBuffer works for size=0, and in fact we call ResizeBuffer(0) in dtor.

lib/tsan/rtl/tsan_sync.cc
82

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?