You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TSan was never released in the NDK, so this is more of a feature request. @yabinc did have it working in the platform, but there are other components that would be needed in the NDK to actually let app developers enable it.
TSAN uses a TLS slot to store thread specific state. Bionic added that support in Android N as slot 8, but changed to slot 6 in Android Q. The tsan library still uses slot 8.
So currently the platform tsan is broken. I think we need to add dynamic detection of android version in tsan library.
no, no news. it's still on the to-do list, but relatively low priority because pretty much everyone actually wants this for their apps (a problem we don't know how to solve, because of the ART side of things) rather than for their stand-alone unit test binaries (a problem we probably could solve).
(it was higher priority when we thought we could at least enable unit tests relatively cheaply, but we've hit a phase that requires some pretty significant investigation and potentially a rework of how sanitizer internals work on android that that's no longer the case)
@DanAlbert Thank you for all your hard work. I noticed the presence of libclang_rt.tsan-aarch64-android.so in NDK r26, and naturally assumed that TSan was supported. With this in mind, I proceeded with a multi-threaded project using the NDK, thinking that any data race issues in multi-threading could be easily resolved with TSan later on. Now that the time has come to address these issues, I find myself needing to use TSan. Is there any alternative method available? Also, could you provide any information on when TSan might be supported?
Activity
enh commentedon Jul 12, 2019
i know @yabinc had this working (for the platform) at one point, but it may have bitrotted. @eugenis might also know something useful...
eugenis commentedon Jul 12, 2019
That's basically all I know. Upstream tests are disabled (and AFAIK have never been enabled), so it is likely broken at this point.
stephenhines commentedon Jul 12, 2019
TSan was never released in the NDK, so this is more of a feature request. @yabinc did have it working in the platform, but there are other components that would be needed in the NDK to actually let app developers enable it.
yabinc commentedon Jul 12, 2019
TSAN uses a TLS slot to store thread specific state. Bionic added that support in Android N as slot 8, but changed to slot 6 in Android Q. The tsan library still uses slot 8.
So currently the platform tsan is broken. I think we need to add dynamic detection of android version in tsan library.
To use tsan on android, we need a tsan shared library linked and available on device, as https://android-review.googlesource.com/c/platform/prebuilts/clang/host/linux-x86/+/516421/1/Android.bp#253. static linking libtsan might also be possible, I didn't remember why we chose to use shared library.
llvm-symbolizer is also needed on device to report data race locations.
equeim commentedon Jul 12, 2019
asan and ubsan have shared libraries in ndk, which can be bundled with apps. tsan for some reason has only static library.
haolongzhangm commentedon Jul 18, 2019
aarch64-linux-android-clang++ -fsanitize=thread -O0 -fno-omit-frame-pointer -g -pie -fPIE -L/home/zhl/mycode/tmp_aosp_for_tsan/aosp/prebuilts/clang/host/./linux-x86/clang-r349610b/lib64/clang/8.0.9/lib/linux/ -lclang_rt.tsan-aarch64-android main.cc -o android_test_tsan
tsan_interceptors.cc:1747: undefined reference to `fileno_unlocked'
extern "C" int fileno_unlocked(void *stream); at tsan_interceptors.cc
but fileno_unlocked defined in libc:
int fileno_unlocked(FILE* __fp)
haolongzhangm commentedon Jul 18, 2019
issue same libclang_rt.tsan-aarch64-android.a link a different version of libc with NDK default libc.so?
int fileno_unlocked(FILE* __fp)
int fileno_unlocked(void *stream)
different args ?
any idea about this? rebuild NDK?
DanAlbert commentedon Jul 18, 2019
Rebuilding will just rebuild the bug. TSan needs to be fixed to work for Android. This isn't currently supported.
[-][BUG] Missing TSAN runtime support?[/-][+][FR] Missing TSAN runtime support?[/+]23 remaining items
enh-google commentedon Jul 18, 2022
yeah, not finished yet but still working on it. (and you're right: it'll be in the release notes when we think it's finished :-) )
shixpGit commentedon Jul 6, 2023
same result with testing on NDK25b, @enh-google Hi~ is there some latest news about this issue? :)
enh-google commentedon Jul 6, 2023
no, no news. it's still on the to-do list, but relatively low priority because pretty much everyone actually wants this for their apps (a problem we don't know how to solve, because of the ART side of things) rather than for their stand-alone unit test binaries (a problem we probably could solve).
DanAlbert commentedon Jul 11, 2023
(it was higher priority when we thought we could at least enable unit tests relatively cheaply, but we've hit a phase that requires some pretty significant investigation and potentially a rework of how sanitizer internals work on android that that's no longer the case)
bibop4 commentedon Aug 29, 2024
@DanAlbert Thank you for all your hard work. I noticed the presence of libclang_rt.tsan-aarch64-android.so in NDK r26, and naturally assumed that TSan was supported. With this in mind, I proceeded with a multi-threaded project using the NDK, thinking that any data race issues in multi-threading could be easily resolved with TSan later on. Now that the time has come to address these issues, I find myself needing to use TSan. Is there any alternative method available? Also, could you provide any information on when TSan might be supported?
DanAlbert commentedon Aug 29, 2024
Nothing's changed since our last update.
Space-desing commentedon Oct 19, 2024
airpfei commentedon Jun 13, 2025
I’m going to support TSan on Android. Is there a guide on how I can contribute to the project?
enh-google commentedon Jun 13, 2025
depends on where you need to make changes. changes to the tsan implementation itself would go in upstream llvm. changes to Android would go to AOSP.
[compiler-rt][TSan] Add support for Android (#147580)
Automerge: [compiler-rt][TSan] Add support for Android (#147580)
airpfei commentedon Oct 13, 2025
DanAlbert commentedon Oct 13, 2025
[compiler-rt][TSan] Add support for Android (#147580)
PLE-544: confirm NDK r28 TSan CHECK failure is not API-36-specific