[compiler-rt] [tsan] Fix build for FreeBSD and NetBSD after 0784b1eefa36 (PR #79019)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 09:59:06 PST 2024


thurstond wrote:

Thanks for the patch! Sorry for the breakage.

> Now that I look at this again, I notice that the shared `CheckASLR()` (https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp#L2261) is already called _before_ `__tsan::InitializePlatformEarly()`:
> 
> https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp#L695
> 
> So why is there any need to check for ASLR again in `ReExecIfNeeded()`? It would already have been re-exec'd at this point?

CheckASLR() unconditionally disables ASLR (or instructs the user to that effect) for some platforms, such as NetBSD and FreeBSD. It's a very simple check that does not need to inspect the memory mappings for compatibility, because it will always disable ASLR for those platforms.

TSan on Linux, however, does support some degree of ASLR (e.g., the default of 28-bits of entropy). ReExecIfNeeded() checks if the address space layout is compatible with TSan; if not, then it disables ASLR. But in the common case, it will not disable ASLR.

https://github.com/llvm/llvm-project/pull/79019


More information about the llvm-commits mailing list