0.9.1 --- the second register comes back from every call - #20
Merged
Conversation
This kernel returns a second value in x1 (rdx on x86_64) from every system call, and the wrapper declared that register an input only. An optimizing compiler therefore kept the first argument there across the call: the preopen table stored the address of "/" from x1 after openat had cleared it, and every program built with --release faulted in kal_fs_preopen before main. The register is now an output as well. -fno-builtin keeps a counting loop from becoming strlen, and CI runs this package's tests and the independence check in both profiles.
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every program built with
--releaseover openkal-macos faulted beforemain.Found through lsp-mcpp: the release server, and a minimal
import std; std::printlnprogram over openkal-llvm-runtime 0.9.4, both stop in the C library's initializer on macos-14:This kernel returns a second value in x1 from every system call (rdx on x86_64) and writes it whether or not the call has one;
duplicate()andpipe_pair()already read it. The genericsys()declared x1 an input only, so an optimizing compiler assumed it survived the call. The releasetable(), disassembled:kal_fs_preopen(1)then copied the name from address zero. The dev profile keeps nothing in a register across a call, which is why it never showed.src/sys.h: x1 is an output ofsys()as well as an input on arm64, and rdx on x86_64. Compiled with-O2,table()now keeps"/"in a callee-saved register across the call.-fno-builtinbeside-fno-exceptions -fno-rtti -fno-stack-protector: the same release build turnedokm::lengthinto a call tostrlen, a C library symbol this package does not reference by design (openkal-windows 0.7.1 made the same change for the same reason).conformance_process_taskenumerates every preopen and is what would have failed.Every source compiles with
-O2for arm64 and x86_64 macOS, and the arm64 object has no undefinedstrlen. The release rows of this CI are the measurement on the machine itself.