Skip to content

Commit fc06246

Browse files
committed
ci(quality-runners): lower ASLR entropy for ThreadSanitizer tests
The mpmc_concurrent_queue_tsan_test in score_lifecycle_health aborts with 'FATAL: ThreadSanitizer: unexpected memory mapping' on Ubuntu 24.04 runners, where vm.mmap_rnd_bits defaults to 32. That high ASLR entropy is incompatible with the sanitizer shadow-memory layout. Lower it to 28 before running the unit tests (google/sanitizers#1614). Best-effort so local runs are unaffected.
1 parent b4c3f10 commit fc06246

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

scripts/quality_runners.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from dataclasses import dataclass
1818
from pathlib import Path
1919
from pprint import pprint
20-
from subprocess import PIPE, Popen
20+
from subprocess import PIPE, Popen, run
2121

2222
from known_good.models.known_good import load_known_good
2323
from known_good.models.module import Module
@@ -34,6 +34,31 @@ def print_centered(message: str, width: int = 120, fillchar: str = "-") -> None:
3434
print(message.center(width, fillchar))
3535

3636

37+
def configure_aslr_for_sanitizers() -> None:
38+
"""Lower ASLR entropy so ThreadSanitizer/ASan tests can run.
39+
40+
Modern kernels (e.g. Ubuntu 24.04 CI runners) default ``vm.mmap_rnd_bits``
41+
to 32. That is incompatible with the sanitizer shadow-memory layout and
42+
makes ThreadSanitizer abort before any test runs with
43+
``FATAL: ThreadSanitizer: unexpected memory mapping``. Lowering the value
44+
to 28 is the documented workaround (see google/sanitizers#1614).
45+
46+
Best-effort: silently ignored when sudo/sysctl is unavailable or the value
47+
is already low enough, so local runs without privileges are unaffected.
48+
"""
49+
print_centered("QR: Configuring ASLR entropy for sanitizer tests")
50+
result = run(
51+
["sudo", "sysctl", "-w", "vm.mmap_rnd_bits=28"],
52+
capture_output=True,
53+
text=True,
54+
check=False,
55+
)
56+
if result.returncode == 0:
57+
print(result.stdout.strip())
58+
else:
59+
print(f"QR: Could not lower vm.mmap_rnd_bits (continuing anyway): {result.stderr.strip()}")
60+
61+
3762
def run_unit_test_with_coverage(module: Module) -> dict[str, str | int]:
3863
print_centered("QR: Running unit tests")
3964

@@ -282,6 +307,7 @@ def parse_arguments() -> argparse.Namespace:
282307

283308
def main() -> bool:
284309
args = parse_arguments()
310+
configure_aslr_for_sanitizers()
285311
args.coverage_output_dir.mkdir(parents=True, exist_ok=True)
286312
path_to_docs = Path(__file__).parent.parent / "docs/verification_report"
287313
path_to_docs.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)