-
Notifications
You must be signed in to change notification settings - Fork 260
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
[FR] Missing TSAN runtime support? #1041
Comments
That's basically all I know. Upstream tests are disabled (and AFAIK have never been enabled), so it is likely broken at this point. |
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. 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. |
asan and ubsan have shared libraries in ndk, which can be bundled with apps. tsan for some reason has only static library. |
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: |
issue same libclang_rt.tsan-aarch64-android.a link a different version of libc with NDK default libc.so? int fileno_unlocked(FILE* __fp) different args ? any idea about this? rebuild NDK? |
Rebuilding will just rebuild the bug. TSan needs to be fixed to work for Android. This isn't currently supported. |
@DanAlbert @equeim 1: build tsan.so: 2: put step 1 build so: libclang_rt.tsan.so 3: build you test file: TMP test ok but may test more case: xiaomi_9:~/zhl$ ./android_test_tsanWARNING: ThreadSanitizer: data race (pid=23331) Previous write of size 4 at 0x00555556b018 by thread T1: Location is global '' at 0x000000000000 (android_test_tsan+0x000000016018) Thread T2 (tid=23334, running) created by main thread at: Thread T1 (tid=23333, finished) created by main thread at: SUMMARY: ThreadSanitizer: data race (/data/data/com.termux/files/home/zhl/android_test_tsan+0xd63) |
would you share the detail that how to build tsan.so? thank you very much |
when i build a sample demo like @haolongzhangm done and run it ,I got crash, details as follows: can anyone tell me why? thanks |
@DanAlbert any idea about my problem? thanks |
until we have someone actually look at what's wrong, no, you probably have more idea than we do since you've actually tried it! fixing tsan is in our plan between now and the Android T release though. (i don't know exactly when we'll get round to it, but it will be released in the next NDK after it's fixed --- we won't hold it hostage until T if it's ready sooner!) |
You can't really use |
Will be great to have this in place at some point. Indeed threading issues need some good tools to help troubleshooting. |
Rest assured, it's being actively worked on. No timeline because we're still in the porting phase and we won't know if we've found the last problem until after we've already fixed it. |
This is actively being worked on but because we can't predict how long porting will take, I'm taking this off the release tracking to make this bug less misleading. Will update here when we can see the light at the end of the tunnel :) |
Bugs: android/ndk#1041 (comment) Tests: Run build.py and verified that shared libs, like libclang_rt.tsan-aarch64-android.so , are present in out/stage2-install/runtimes_ndk_cxx Change-Id: I9612e1be4783c2fd17f6b32fef93869d9fdf7061 Signed-off-by: Jason Edson <[email protected]>
Bugs: android/ndk#1041 (comment) Tests: Run build.py and verified that shared libs, like libclang_rt.tsan-aarch64-android.so , are present in out/stage2-install/runtimes_ndk_cxx Change-Id: I9612e1be4783c2fd17f6b32fef93869d9fdf7061 Signed-off-by: Jason Edson <[email protected]>
Bugs: android/ndk#1041 (comment) Tests: Run build.py and verified that shared libs, like libclang_rt.tsan-aarch64-android.so , are present in out/stage2-install/runtimes_ndk_cxx Change-Id: I9612e1be4783c2fd17f6b32fef93869d9fdf7061 Signed-off-by: Jason Edson <[email protected]>
Bugs: android/ndk#1041 (comment) Tests: Run build.py and verified that shared libs, like libclang_rt.tsan-aarch64-android.so , are present in out/stage2-install/runtimes_ndk_cxx Change-Id: I9612e1be4783c2fd17f6b32fef93869d9fdf7061 Signed-off-by: Jason Edson <[email protected]>
Bugs: android/ndk#1041 (comment) Tests: Run build.py and verified that shared libs, like libclang_rt.tsan-aarch64-android.so , are present in out/stage2-install/runtimes_ndk_cxx Change-Id: I9612e1be4783c2fd17f6b32fef93869d9fdf7061 Signed-off-by: Jason Edson <[email protected]>
Bugs: android/ndk#1041 (comment) Tests: Run build.py and verified that shared libs, like libclang_rt.tsan-aarch64-android.so , are present in out/stage2-install/runtimes_ndk_cxx Change-Id: I9612e1be4783c2fd17f6b32fef93869d9fdf7061
I saw that r25 has TSan runtime libs, so jumped on it to test it.
release notes didn't mention TSan support, so I guess it's not fixed yet and we have to wait more? |
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 :-) ) |
same result with testing on NDK25b, @enh-google Hi~ is there some latest news about this issue? :) |
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? |
Nothing's changed since our last update. |
Description
Add -fsanitize=thread to compile and link flags, and get
error: undefined reference to '__tsan_func_entry'
(and other tsan functions) link errors.Environment Details
The text was updated successfully, but these errors were encountered: