hanchenye-llvm-project/compiler-rt/lib
Chandler Carruth 1a48dc5ed6 Fix a veritable conucopia of bugs in the readdir_r interceptors.
First, the reason I came here: I forgot to look at readdir64_r which had
the exact same bug as readdir_r. However, upon applying the same
quick-fix and testing it I discovered that it still didn't work at all.
As a consequence, I spent some time studying the code and thinking about
it and fixed several other problems.

Second, the code was checking for a null entry and result pointer, but
there is no indication that null pointers are viable here. Certainly,
the spec makes it extremely clear that there is no non-error case where
the implementation of readdir_r fails to dereference the 'result'
pointer and store NULL to it. Thus, our checking for a non-null 'result'
pointer before reflecting that write in the instrumentation was
trivially dead. Remove it.

Third, the interceptor was marking the write to the actual dirent struct
by looking at the entry pointer, but nothing in the spec requires that
the dirent struct written is actually written into the entry structure
provided. A threadlocal buffer would be just as conforming, and the spec
goes out of its way to say the pointer to the *actual* result dirent
struct is stored into *result, so *that* is where the interceptor should
reflect a write occuring. This also obviates the need to even consider
whether the 'entry' parameter is null.

Fourth, I got to the bottom of why nothing at all worked in readdir64_r
-- the interceptor structure for dirent64 was completely wrong in that
it was the same as dirent. I fixed this struct to be correct (64-bit
inode and 64-bit offset! just a 64-bit offset isn't enough!) and added
several missing tests for the size and layout of this struct.

llvm-svn: 186109
2013-07-11 18:51:40 +00:00
..
arm <rdar://problem/12512722> Use arm divide instruction if available 2013-05-24 19:38:11 +00:00
asan Fix a veritable conucopia of bugs in the readdir_r interceptors. 2013-07-11 18:51:40 +00:00
i386
interception [libsanitizer] Introduce INTERCEPTOR_WITH_SUFFIX which is to be used for appending the __DARWIN_ALIAS() version suffixes to function names on Darwin. 2013-05-20 13:32:35 +00:00
lsan [lsan] Fix test. 2013-07-08 14:08:05 +00:00
msan [sanitizer] More checks in mbstowcs-like interceptors. 2013-07-10 14:17:46 +00:00
msandr [msan] Get rid of "using std::string" in msandr. 2013-03-22 08:47:42 +00:00
ppc
profile Revert hack that omits errno on Darwin platforms. We now have an acceptable 'errno' header. 2013-06-27 21:17:53 +00:00
sanitizer_common Fix a veritable conucopia of bugs in the readdir_r interceptors. 2013-07-11 18:51:40 +00:00
tsan [sanitizer] Support GLOB_ALTDIRFUNC in glob interceptor. 2013-07-09 12:07:59 +00:00
ubsan [ASan] create separate configs for running ASan lit tests in both 32- and 64-bit mode. Clean up RUN-lines in tests. 2013-06-07 09:38:55 +00:00
x86_64
CMakeLists.txt Add cmake rules for building LSan common on Mac OS 2013-06-22 16:33:52 +00:00
Makefile.mk Revert r182465 and add lsan-common library to makefile-based build 2013-05-22 13:20:37 +00:00
absvdi2.c
absvsi2.c
absvti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
adddf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
addsf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
addvdi3.c
addvsi3.c
addvti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
apple_versioning.c <rdar://problem/13806954> enable __atomic_* functions for Darwin 2013-05-21 23:02:04 +00:00
ashldi3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
ashlti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
ashrdi3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
ashrti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
assembly.h <rdar://problem/11668446> Add .subsections_via_symbols to Darwin assembly files 2012-07-11 19:21:39 +00:00
atomic.c <rdar://problem/13806954> enable __atomic_* functions for Darwin 2013-05-21 23:02:04 +00:00
clear_cache.c
clzdi2.c
clzsi2.c
clzti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
cmpdi2.c Implement __aeabi_lcmp and ulcmp 2013-01-13 19:18:02 +00:00
cmpti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
comparedf2.c Implement aeabi_{f,d}cmp*. 2013-02-07 08:29:47 +00:00
comparesf2.c Implement aeabi_{f,d}cmp*. 2013-02-07 08:29:47 +00:00
ctzdi2.c
ctzsi2.c
ctzti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
divdc3.c
divdf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
divdi3.c
divmoddi4.c
divmodsi4.c
divsc3.c
divsf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
divsi3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
divti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
divxc3.c
enable_execute_stack.c
eprintf.c
extendsfdf2.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
ffsdi2.c
ffsti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fixdfdi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixdfsi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixdfti.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fixsfdi.c Correct name of __aeabi_f2lz. 2013-01-13 19:18:00 +00:00
fixsfsi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixsfti.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fixunsdfdi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixunsdfsi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixunsdfti.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fixunssfdi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixunssfsi.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
fixunssfti.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fixunsxfdi.c
fixunsxfsi.c
fixunsxfti.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fixxfdi.c
fixxfti.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
floatdidf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatdisf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatdixf.c
floatsidf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatsisf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floattidf.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
floattisf.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
floattixf.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
floatundidf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatundisf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatundixf.c
floatunsidf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatunsisf.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
floatuntidf.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
floatuntisf.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
floatuntixf.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
fp_lib.h Declare some variables unsigned to avoid signed vs unsigned mismatches. 2012-06-18 18:51:13 +00:00
gcc_personality_v0.c
int_endianness.h Both OpenBSD and Bitrig need to include machine/endian.h to get the 2012-09-20 06:19:20 +00:00
int_lib.h
int_math.h
int_types.h
int_util.c
int_util.h
lit.common.cfg Define the path to llvm-symbolizer tool in a common config to reduce copy-paste 2013-06-30 14:47:38 +00:00
lit.common.configured.in Remove a bunch of copy-paste: use common config for sanitizer lit/unit tests 2013-06-06 13:28:37 +00:00
lit.common.unit.cfg Use LLVM_BUILD_TYPE instead of CMAKE_BUILD_TYPE in compiler-rt unit tests to match the behavior of llvm unittests 2013-01-30 12:18:49 +00:00
lit.common.unit.configured.in Remove a bunch of copy-paste: use common config for sanitizer lit/unit tests 2013-06-06 13:28:37 +00:00
lshrdi3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
lshrti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
moddi3.c
modsi3.c
modti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
muldc3.c
muldf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
muldi3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
mulodi4.c
mulosi4.c
muloti4.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
mulsc3.c
mulsf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
multi3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
mulvdi3.c
mulvsi3.c
mulvti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
mulxc3.c
negdf2.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
negdi2.c
negsf2.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
negti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
negvdi2.c
negvsi2.c
negvti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
paritydi2.c
paritysi2.c
parityti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
popcountdi2.c
popcountsi2.c
popcountti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
powidf2.c
powisf2.c
powitf2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
powixf2.c
subdf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
subsf3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
subvdi3.c
subvsi3.c
subvti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
trampoline_setup.c
truncdfsf2.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
ucmpdi2.c Implement __aeabi_lcmp and ulcmp 2013-01-13 19:18:02 +00:00
ucmpti2.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
udivdi3.c
udivmoddi4.c
udivmodsi4.c
udivmodti4.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
udivsi3.c Remove extraneous semicolons outside of functions. This fixes a large 2012-06-22 21:09:15 +00:00
udivti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00
umoddi3.c
umodsi3.c
umodti3.c Mechanical change to sink a #ifdef guard for a platform below the 2012-06-22 21:09:22 +00:00