You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lib/ubsan: integer-divide-by-zero sanitizer is never enabled in custom mode #1946
Config.uk defines LIBUBSAN_SAN_DIV_BY_ZERO, so the ZEOR one is never set and -fsanitize=integer-divide-by-zero never gets added. The default mode uses -fsanitize=undefined, so it's fine there.
I built a small app that divides by a volatile zero and ran it on QEMU (kvm, x86_64 and arm64).
integer-divide-by-zero is missing from the -fsanitize flags in compile_commands.json, and there is no UBSan report at runtime. On arm64 it just prints 0, on x86_64 it hits the divide error trap.
Expected behavior
UBSan should report the division by zero. Changing ZEOR to ZERO in the Makefile fixes it, I tested this on both x86_64 and arm64. I'll send a PR.
Which architectures were you using or does this bug affect?
No response
Which platforms were you using or does this bug affect?
No response
Relevant log output
arm64, before:
[libubsan] Undefined behavior at main.c:7:33: shift of 42 by 40 out of bounds fortype'int'
[test] div: 0
arm64, after fix:
[libubsan] Undefined behavior at main.c:7:33: shift of 42 by 40 out of bounds fortype'int'
[libubsan] Undefined behavior at main.c:8:33: division by zero
[test] div: 0
Activity