This is an archive of the discontinued LLVM Phabricator instance.

[LSAN][NFC] Eliminated GetThreadRegistryLocked from the LSAN interface to avoid the need to implement it in HWASAN.
ClosedPublic

Authored by kstoimenov on Dec 13 2022, 3:06 PM.

Diff Detail

Event Timeline

kstoimenov created this revision.Dec 13 2022, 3:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 3:06 PM
kstoimenov requested review of this revision.Dec 13 2022, 3:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 3:06 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Some updates.

vitalybuka added inline comments.Dec 13 2022, 3:16 PM
compiler-rt/lib/lsan/lsan_posix.cpp
65

Here we need to get into specific lsan/asan or hwasan thread registry
with this patch it's always lsan

you probably need lsan::FindThreadContextByOsIDLocked then?

compiler-rt/lib/lsan/lsan_thread.h
48

Why do you need this in header?
Maybe just static in cpp file?

Adde GetLsanThreadRegistryLocked back.

kstoimenov added inline comments.Dec 13 2022, 3:30 PM
compiler-rt/lib/lsan/lsan_posix.cpp
65

Actually it should be the lsan specific "GetTreadRegistry" because GetThreadRangesLocked is part of the lsan link-time interface. In HWASAN we might not even use TreadRegistry at all.

compiler-rt/lib/lsan/lsan_thread.h
48

It is used by lsan_posix.cc.

vitalybuka added inline comments.Dec 13 2022, 3:33 PM
compiler-rt/lib/lsan/lsan_posix.cpp
65

Yes, but with asan we have no GetLsanThreadRegistryLocked, FindThreadContextByOsIDLocked should look into asan thread registry

kstoimenov added inline comments.Dec 13 2022, 3:46 PM
compiler-rt/lib/lsan/lsan_posix.cpp
65

Well, asan has it's own implementation of GetThreadRangesLocked: https://tinyurl.com/4hf7a5cx and it is not using the TreadRegistry at all.

kstoimenov added inline comments.Dec 13 2022, 3:51 PM
compiler-rt/lib/lsan/lsan_posix.cpp
65

If we have to be pedantic __asan::GetAsanThreadByOsIDLocked uses the registry so technically it is using it indirectly through another function. But still we don't need to provide generic implementation for GetThreadRegistryLocked which is the point of this patch.

vitalybuka accepted this revision.Dec 13 2022, 3:55 PM
This revision is now accepted and ready to land.Dec 13 2022, 3:55 PM
This revision was landed with ongoing or failed builds.Dec 13 2022, 4:16 PM
This revision was automatically updated to reflect the committed changes.