This is an archive of the discontinued LLVM Phabricator instance.

[lsan][test] Obtaining page size using sysconf(_SC_PAGESIZE)
ClosedPublic

Authored by Ami-zhang on Apr 14 2023, 7:43 PM.

Details

Summary

The effectiveness of the mprotect function depends on whether
the first argument is aligned to a page boundary. If mprotect
doesn't work, the kernel will not generate a SIGSEGV signal for
the process when the calling process tries to access memory in
a manner that violates the protection. If so, this test fails.

The problem for this test is that it uses a fixed 4 kB page size
and is aligned. This fails when the page size is not 4 kB. For
example, this fails on LoongArch which uses a 16 kB pagesize.

Diff Detail

Event Timeline

Ami-zhang created this revision.Apr 14 2023, 7:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 7:43 PM
Herald added a subscriber: Enna1. · View Herald Transcript
Ami-zhang requested review of this revision.Apr 14 2023, 7:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 7:43 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
Ami-zhang edited the summary of this revision. (Show Details)Apr 14 2023, 8:08 PM
SixWeining accepted this revision.Apr 19 2023, 4:58 AM

LGTM and wait for others.

This revision is now accepted and ready to land.Apr 19 2023, 4:58 AM
vitalybuka accepted this revision.Apr 19 2023, 11:14 AM
xen0n accepted this revision.Apr 19 2023, 11:26 AM

Although I'd name the variable pagesize_mask if doing this myself, I'm not particularly picky about this. Apparently we can expect people to understand that a power-of-2 minus one automatically becomes a mask...

MaskRay accepted this revision.Apr 19 2023, 12:27 PM
MaskRay added inline comments.
compiler-rt/test/lsan/TestCases/Linux/leak_check_segv.cpp
2

We don't use clang-format markers in tests. And we don't clang-format tests.

Although I'd name the variable pagesize_mask if doing this myself, I'm not particularly picky about this. Apparently we can expect people to understand that a power-of-2 minus one automatically becomes a mask...

Okay, thanks for your suggestion. I have modified it.

compiler-rt/test/lsan/TestCases/Linux/leak_check_segv.cpp
2

Ok.

Ami-zhang updated this revision to Diff 515290.Apr 20 2023, 5:24 AM

Addressed @xen0n's and @MaskRay's comments.

Ami-zhang updated this revision to Diff 516225.Apr 23 2023, 8:48 PM

Clang-format this file.

This revision was automatically updated to reflect the committed changes.