Trap unsigned wrap-around in tests/dlssg_pace_check.py, as its comment on overflows promised.

The review found that the comment said an overflow in the period arithmetic fails the check, but -fsanitize=undefined
does not trap unsigned wrap-around, and every period and time in runtime/dlssg_pace.h is a uint64_t. The check now
builds with -fsanitize=undefined,unsigned-integer-overflow and the same -fsanitize-trap list, and the comment says
why. It passes; a uint64_t subtraction that wraps traps under these flags and runs on under the old ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 19:24:18 -05:00
parent 46bf4823e6
commit 358713fbf2

View File

@@ -31,9 +31,12 @@ def main():
env = dict(os.environ)
if os.name == 'nt' and MSYS_BIN.exists():
env['PATH'] = str(MSYS_BIN) + os.pathsep + env.get('PATH', '')
# undefined behaviour traps: an overflow in the period arithmetic fails the check instead of passing by chance
subprocess.check_call([compiler(), '-std=gnu11', '-O1', '-Wall', '-Werror', '-fsanitize=undefined',
'-fsanitize-trap=undefined', '-I', str(ROOT / 'runtime'),
# undefined behaviour and unsigned wrap-around trap: every period and time in dlssg_pace.h is a uint64_t, which
# -fsanitize=undefined alone lets wrap, so an overflow in that arithmetic fails the check instead of passing by
# chance
ub = 'undefined,unsigned-integer-overflow'
subprocess.check_call([compiler(), '-std=gnu11', '-O1', '-Wall', '-Werror', f'-fsanitize={ub}',
f'-fsanitize-trap={ub}', '-I', str(ROOT / 'runtime'),
str(ROOT / 'tests' / 'dlssg_pace_check.c'), '-o', str(exe)], env=env)
return subprocess.run([str(exe)], env=env).returncode