[compiler-rt] [TSan] Clarify and enforce shadow end alignment (PR #144648)

Kunqiu Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 02:16:55 PDT 2025


Camsyn wrote:

> Consider reverting this commit, and then re-committing with the fix.
After debugging, I found that it is a behavior difference of `ReleaseMemoryPagesToOS` between IOS and Linux.

In IOS, it executes `madvise(beg, end, MADV_FREE)`, which tags the relevant pages as 'FREE' and does not release them immediately.
In Linux, it executes `madvise(beg, end, MADV_DONTNEED)`, releasing the pages immediately and setting them to 0.

Therefore, in IOS, ` __tsan_read1(&buf[0]);` still raises a race error even after `munmap` 'clears' the relevant shadow pages.

I think we need to change the test case to one of the following fixes:
1. Directly verify the page status rather than expect `__tsan_read1` not to raise an error (For an end-to-end testcase, this is too detailed).
2. Turn off the test case `munmap_clear_shadow.c`, because TSan does not provide a direct API query whether the shadow pages are cleared.

Do you think which fix is better, or can you give a better suggestion? @melver 

After confirming the fix, I will propose another Reland PR. Or for such a simple testcase-only fix, should I just fix-forward without revert?


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


More information about the llvm-commits mailing list