The following functions are only used in tests: SetEnv,
SanitizerSetThreadName, SanitizerGetThreadName. I don't think they are
going to be used in the future, and I propose to get rid of them, and associated
tests and include.
Details
Diff Detail
- Repository
- rCRT Compiler Runtime
Event Timeline
lib/sanitizer_common/sanitizer_common.h | ||
---|---|---|
272 | this one is used by external code, check __sanitizer::SetEnv google3 |
I am not following. Isn't it a test for prctl interceptor? Why are we removing useful tests?
Perhaps it's not the most critical functionality. And perhaps SanitizerSetThreadName needs to be moved to the test itself. But still it's a test.
Here is my understanding, please let me know if I am wrong:
- Unless mistaken, sanitizer_common_test.cc doesn't involve interceptors, just the tests for the common functions.
- Sanitizer{S,G}etThreadName use prctl and not internal_prctl which might cause problems if they were to be used with interceptors.
- The test removed only tests that actual prctl PR_{G,S}ET_NAME behaves somewhat appropriately, which is probably not that useful.
I tried to verify all this and ran the test manually with a breakpoint on libc's prctl:
[ RUN ] SanitizerCommon.SanitizerSetThreadName Breakpoint 1, 0x00007ffff6c592c0 in prctl () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0 0x00007ffff6c592c0 in prctl () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x000000000054fbd7 in __sanitizer::SanitizerSetThreadName(char const*) () at sanitizer_linux_libcdep.cc:167 #2 0x0000000000495db4 in TestBody () at sanitizer_common_test.cc:100
I think TryToSetThreadName in asan_test.cc leverages an intercepted prctl for this purpose.
I didn't find anything that suggested that this particular one was, but someone else can probably chime in on that.
sanitizer::SanitizerSetThreadName is present in other binaries (Asan-x86-64-calls-Tests for example) and calls interceptor_prctl there, but is not called by anything.
asan_test.cc leverages an intercepted prctl with the ThreadedTestFunc test which calls:
static bool TryToSetThreadName(const char *name) { #if defined(__linux__) && defined(PR_SET_NAME) return 0 == prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0); #else return false; #endif }
and checks the names to be right in the death message.
this one is used by external code, check __sanitizer::SetEnv google3