This fixes sanitizer issue #696: when the GNU version of strerror_r returns a result pointer that doesn't match the input buffer, that result pointer is in fact a pointer to some immutable storage that is part of the library (namely sys_errlist). TSAN is currently recording a write to this location, which is incorrect.
Details
Diff Detail
- Build Status
Buildable 7044 Build 7044: arc lint + arc unit
Event Timeline
As a drive-by contributor, I didn't really know how to write a test for this. But I verified in my application that this fixes a false positive.
For a test, look at test/tsan/race_on_puts.cc
The same template with strerror_r called in two threads should do the trick.
lib/sanitizer_common/sanitizer_common_interceptors.inc | ||
---|---|---|
3230 | else COMMON_INTERCEPTOR_INITIALIZE_RANGE ( same args ) |
I have some other high priority work for the next couple weeks, so may be a while before I can get back to this patch and add a test. If someone else is interested in carrying it over the finish line in the meantime, please feel free, otherwise I'm likely to pick it up in mid December or January.
Somehow I missed review URL in my patch description, so closing manually.
https://llvm.org/svn/llvm-project/compiler-rt/trunk@304858
else COMMON_INTERCEPTOR_INITIALIZE_RANGE ( same args )
This would count as an initializing write for MSan, but not for TSan.