Main goal is to remove thread registry dependency from the interface because HWASAN is using its own code to manage threads.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 | I am not sure I like that not suspended/unsuspended logic is exposed to asan |
I am not sure what is the problem here for HWASAN
It's going to use ThreadContextBase anyway?
Currently HWASAN is using HwasanThreadList to manage the threads. I am thinking that I could adapt this class to do what the ThreadRegistry does, but for that I will have to clean up the interface. So I am trying to get rid of anything that is ThreadRegistry related including ThreadContextBase.
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 | Probably it would be nicer if you have |
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 |
Why you don't want to go this way? |
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 | In some cases like for example GetAdditionalThreadContextPtrs for the LSAN implementation the actual callback is empty. In the current implementation we would still enumerate all threads and call an empty callback which is less efficient. |
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 | Which implementations? Also even in extremely thread apps, number of threads is a relatively small number |
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 | What I mean is that if we use RunCallbackForEachThreadLocked and the callback is empty we will still run a loop over all threads and call an empty callback. Also it is not only about the loop, but we also lock the allocator when we run the loop. Let me try to do it your way. |
compiler-rt/lib/asan/asan_thread.cpp | ||
---|---|---|
553 | I tried using exposing generic RunCallbackForEachRunningThreadLocked, but it is very kludgy. In this case RunCallbackForEachRunningThreadLocked and each callback have to be implemented by individual client (hwasan, asan, lsan). This leads to a problem with the callback because to implement RunCallbackForEachRunningThreadLocked I need to cast the generic callback that is passed into the concrete type, but this is not possible. I tried using a lambda, but I need to capture the original callback and according to the C++ standard this cannot be use and function pointer. See D141621 for details. |
Looks like this doesn't build on Windows: http://45.33.8.238/win/73274/step_4.txt
Please take a look and revert for now if it takes a while to fix.
If you revert instead of a fix forward would you mind reverting rGf001e50f955c3cdf2deb79e38a9fd19c9a781882 too?
Hmm, the update I did to lsan_common_fuchsia.cpp is fine for clang_rt.lsan, but unfortunately it breaks clang_rt.asan. I'm pretty sure adding lsan_thread.cpp to LSAN_COMMON_SOURCES is wrong, but it isn't even tenable because then clang_rt.asan gets multiple definition errors between lsan_thread.cpp and asan_thread.cpp. I'm wondering what the best way to go about this is? In lsan we want to use GetLsanThreadRegistryLocked but in asan we want GetAsanThreadRegistryLocked instead. Though this seems erroneous. Do folks have any other suggestions?
I am not sure I like that not suspended/unsuspended logic is exposed to asan