-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[TSan] Add support for Android #147580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[TSan] Add support for Android #147580
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2411,7 +2411,7 @@ TSAN_INTERCEPTOR(int, vfork, int fake) { | |
} | ||
#endif | ||
|
||
#if SANITIZER_LINUX | ||
#if SANITIZER_LINUX && !SANITIZER_ANDROID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? seems like we need to intercept clone() for tsan especially? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. glibc's I'm not sure if this is the best way https://codebrowser.dev/glibc/glibc/nptl/pthread_create.c.html#297 |
||
TSAN_INTERCEPTOR(int, clone, int (*fn)(void *), void *stack, int flags, | ||
void *arg, int *parent_tid, void *tls, pid_t *child_tid) { | ||
SCOPED_INTERCEPTOR_RAW(clone, fn, stack, flags, arg, parent_tid, tls, | ||
|
@@ -3120,7 +3120,7 @@ void InitializeInterceptors() { | |
|
||
TSAN_INTERCEPT(fork); | ||
TSAN_INTERCEPT(vfork); | ||
#if SANITIZER_LINUX | ||
#if SANITIZER_LINUX && !SANITIZER_ANDROID | ||
TSAN_INTERCEPT(clone); | ||
#endif | ||
#if !SANITIZER_ANDROID | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,10 +188,14 @@ void ThreadStart(ThreadState *thr, Tid tid, ThreadID os_id, | |
} | ||
#endif | ||
|
||
#if !SANITIZER_GO | ||
#if !SANITIZER_GO && !SANITIZER_ANDROID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why don't we need this for android? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because ThreadState is created by MmapOrDie, so the thr object is not in tls, the pointer of thr object is in TLS_SLOT_SANITIZER slot. The check in ImitateTlsWrite will fail. https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp#L640
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp#L592
|
||
// Don't imitate stack/TLS writes for the main thread, | ||
// because its initialization is synchronized with all | ||
// subsequent threads anyway. | ||
// Because thr is created by MmapOrDie, the thr object | ||
// is not in tls, the pointer of thr object is in | ||
// TLS_SLOT_SANITIZER slot. So skip this check on | ||
// Android platform. | ||
if (tid != kMainTid) { | ||
if (stk_addr && stk_size) { | ||
const uptr pc = StackTrace::GetNextInstructionPc( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be needed because it's defined in the ndk?