FYI: An example type of UBSAN failure during kyua test -k /usr/tests/Kyuafile

From: Mark Millard <marklmi_at_yahoo.com>
Date: Fri, 07 Jan 2022 11:49:51 UTC
Having done a buildworld with both WITH_ASAN= and WITH_UBSAN=
after finding what to control to allow the build, I installed
it in a directory tree for chroot use and have
"kyua test -k /usr/tests/Kyuafile" running.

I see evidence of various examples of one type of undefined
behavior: "applying zero offset to null pointer"

# more /usr/obj/DESTDIRs/main-amd64-xSAN-chroot/tmp/kyua.FKD2vh/356/stderr.txt 
/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/lib/libc/stdio/fread.c:133:10 in 
/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/lib/libc/stdio/fread.c:133:10 in 
/usr/main-src/usr.bin/sed/process.c:715:18: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/usr.bin/sed/process.c:715:18 in 
/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/lib/libc/stdio/fread.c:133:10 in 
Fail: stderr not empty
--- /dev/null   2022-01-07 10:29:57.182903000 +0000
+++ /tmp/kyua.FKD2vh/356/work/check.Mk9llD/stderr       2022-01-07 10:29:57.173100000 +0000
@@ -0,0 +1,2 @@
+/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying zero offset to null pointer
+SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/main-src/lib/libc/stdio/fread.c:133:10 in 
Files left in work directory after failure: mntpt, mounterr


In general the lib/libc/stdio/fread.c:133:10 example seems to
be in a place that would make it fairly common.

usr.bin/sed/process.c:715:18 is more limited: just sed use.

===
Mark Millard
marklmi at yahoo.com