From 66eb8556317e251fb97d5d284113ae7ada56cf44 Mon Sep 17 00:00:00 2001 From: Ivan Velickovic Date: Tue, 16 Jan 2024 13:49:57 +1100 Subject: [PATCH] examples/simple: disable UBSAN when building with Zig Zig enables UBSAN on C code by default and it seems to be creating weird behaviour. If UB is detected at run-time, the program should panic by executing a `brk` instruction in this case (ARM64 and no OS). It seems that the Microkit event loop is actually doing different things depending on whether or not UBSAN is on. Specifically, the `seL4_NBSendRecv` system call is being made when UBSAN is on, even though it should never be called in this example code (and is not called when we turn UBSAN off). Not sure what's going on, it's still entirely possible that we have UB in our code. More investigation required. --- examples/simple/build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/simple/build.zig b/examples/simple/build.zig index 879b07f1..85dfa880 100644 --- a/examples/simple/build.zig +++ b/examples/simple/build.zig @@ -119,6 +119,7 @@ pub fn build(b: *std.Build) void { "-Werror", "-Wno-unused-function", "-mstrict-align", + "-fno-sanitize=undefined", // @ivanv: ideally we wouldn't have to turn off UBSAN fmtPrint("-DBOARD_{s}", .{ microkit_board }) // @ivanv: shouldn't be needed as the library should not depend on the board } });