Files
reims-vgpu/docs/lessons.md
T
Anees Iqbal 4377c7ebcb 🐛 Link the arm64e bundle with small objc stubs so its set reproduces
Two builds of one tree gave two arm64e RgfxGate binaries, alternating
(three clean builds on the M3 Max: A, B, A). They differed only in the
Metal bundle's arm64e image inside RgfxGate: its UUID, its signature and
__objc_stubs. ld (ld-27106.1) makes two slots for objc_msgSend in the
authenticated GOT, one for the message-send stubs and one for
objc_msgSend's own call stub, and gives each stub its slot in either order
from one link to the next. The arm64 image, whose GOT is not
authenticated, was the same every time.

The arm64e bundle now links its message-send stubs in their small form,
which branch to objc_msgSend's call stub and take no GOT slot of their
own, so the one slot leaves nothing to order. docs/lessons.md records the
trap.
2026-11-08 23:07:49 -08:00

91 lines
68 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Lessons
Each lesson is a trap that decides what the guest or the host sees, or what a check reports,
found by a test, a review or a VM boot: what went wrong, why, and how to recognise the next
one. A new trap found the same way goes here.
## The platform and the runtime
- A model of an Objective-C mechanism must still drive the real one where the platform uses it. A model of `@autoreleasepool` that held Rust values alone left everything Metal autoreleased on the library's threads unreleased (the `+0` `-commandBuffer`, its encoders). Uncommitted command buffers then used up the queue's 64 slots, and the 65th `-commandBuffer` blocked. `rt::Pool` pushes and pops a real pool around each unit of work for that reason (architecture 7.4). Whether a dropped uncommitted buffer is still in the pool depends on the build: an optimized one elides Metal's autorelease of it, and a dev build does not.
- A synchronous Metal compile can wait forever after Metal's compiler service crashes. Metal's compute state of a fragment function crashes `MTLCompilerService` at each of the compile's 4 tries and answers error 2; `compute_state_answers_are_metals_for_every_kernel_here` asks for 50, 200 crashes a run. Now and then the compile never makes its next try: the caller sits in `newComputePipelineStateWithFunction:`, under AGX's `createComputeProgramVariant`, in `_dispatch_group_wait_slow`, at no CPU, with no compiler service left for it, and its log ends at `Compilation failed with XPC_ERROR_CONNECTION_INTERRUPTED on 2 try` (**measured** on the M3 Max, macOS 27.0.1: 3 hangs in 24 runs made 6 at a time, none in 16 alone, and 4 in one day of `cargo xtask check`, one with nothing else of the check running while other builds loaded the host). It looked like a GPU recovery stalling the compile, and is not one: 8 runs beside a test that faulted the GPU throughout, 3,390 GPU events over 1,600 crashed tries, never hung, and no hang had a GPU event within a minute of it. The test now reads Metal's answers recorded once (`metal_answers/`), so it no longer asks Metal's compiler. Any synchronous Metal pipeline creation (`newComputePipelineStateWithDescriptor:options:reflection:error:`, `newRenderPipelineStateWithDescriptor:options:reflection:error:`, `newRenderPipelineStateWithTileDescriptor:options:reflection:error:`) on a thread that must not stop can stop that thread the same way, from a descriptor naming a fragment function in a compute state or from the service dying (a crash other than a fragment function's is not measured). How to spot the next one: a thread in `_dispatch_group_wait_slow` under a Metal `new...PipelineState...` call at no CPU; read the process's log for the compiler's XPC errors and launchd's `MTLCompilerService ... exited due to SIGSEGV` lines. A fragment function compiled from source at run time does the same: each call crashes the service 4 times and answers `AGXMetalG15X_M1` error 2, and of 6 processes making 50 such calls at once, one stopped after the crash at its third try (**measured** on the M3 Max, macOS 27.0.1, 2026-10-26). The log names a client by its executable's name and pid alone (`ParentProcessName=NAME_PID`), and a crash report hides its path, so tie the name to a binary (`ps -o command -p PID` while it runs) before counting its crashes as ours: metal2vulkan's conformance sweeps, run on the same Mac, are a binary named `conformance`, where the video conformance suite runs as `videotoolbox-conformance` and tests as `CRATE-HASH`.
- Leaks that only exhaust a resource show up as "the Nth of anything hangs". When a run starts to differ or hang at exactly the 65th command buffer, suspect `MTLCommandQueue`'s default `maxCommandBufferCount` of 64 and count the uncommitted buffers, not the call that hangs.
- An object autoreleased on the host's thread goes to the host's pool, which the host pops after the API call has returned, and a host in C has no pool at all. A thread-local stack that only the library's own holders and a worker's idle drain empty keeps such values alive forever on a host thread. Every public entry pushes a pool and opens a holder of its own (`reims_vgpu::entry::run`), so what the call held or Metal autoreleased on the host's thread goes before it returns; a thread the library started keeps a last-resort holder and pool for what is held or autoreleased there outside any unit.
- A `dispatch_sync` block runs on the caller's thread, and that is ordering the guest sees, not an implementation detail. A `SerialQueue::sync` that ran the block on the queue's worker and woke the caller afterwards let a child FIFO of the paravirt device (since deleted) overtake the root: `DeviceCore::create_fifo` starts the child's thread inside its sync block, and while the root FIFO thread waited for the wake-up, the new child ran its replayed NOP and raised its interrupt before the root published the define's stamp (`irq_stamps` `["0x2","0x1"]` instead of `["0x3","0x1"]`, one run in ten). `SerialQueue::sync` runs the block on the caller's thread. When an interrupt snapshot flakes, look for a hand-off between threads that the order does not need, not for a lock or a publish order.
- An `@autoreleasepool` a raise leaves is not popped: clang registers the pop as a normal cleanup only, so the enclosing pop (or the host's own) frees what was autoreleased inside it. A pool popped at the raise frees what Metal autoreleased in it too early; `rt::pool::around` leaves it pushed. And a pool pushed only after the body never catches Metal's `+0` returns at all.
- A weak load under MRC with `-fobjc-weak` is `objc_loadWeak`: the object comes back retained and autoreleased into the innermost pool, so its release, and its teardown when that reference was the last, lands at the pool's pop, after what the block did. `Weak::upgrade` into a local drops it at the end of the Rust scope instead, which can run the teardown in the middle of the work. Where an upgraded reference's last release crosses the API, hold it to the end of its hold's holder (`Hold::keep`), or, where that teardown syncs onto the queue running the block, let it go with `rt::held::release_off_thread` (architecture 7.4).
- A wrapper and the library's object are two lifetimes where the host sees one. A block of the library's can keep a display after the host's last release of the handle that wraps it, and the library's teardown then runs later, on that block's thread. A callback the library makes from its teardown must not take the wrapper as its context: hand it what the wrapper held. The C API's display callbacks each hold the host's callback table, not the `RvgDisplay` handle, and the table's `destroy` runs when the last of them goes ([api.md](api.md) section 5, "Callback tables and their destroys").
- A `+0` message send to an unretained pointer takes no reference, so it can never be the last release. `Weak::upgrade` into a temporary is a retain and a release: when the host's release lands meanwhile, the temporary's drop runs the teardown on the sender's thread, under the sender's locks (a detach that takes the same lock hangs), and for an object whose last release has already begun the upgrade fails where an unretained pointer still reaches the object. Reach the object without a reference wherever the code sends to a pointer it does not own: `DeviceCore::display_core` does, for the device's port table and the guest display's client, taking the display's core and never a reference to the host's display.
- A queue worker's idle drain is the last-resort holder's release and pool pop, after the thread has left the queue: a teardown released there may `sync` onto that same queue (the device's teardown onto its reporting queue), and libdispatch runs what is pending on another worker first. A `sync` that waits for "the worker" to hand over the turn hangs when the caller is that worker; `SerialQueue::sync` runs the blocks queued ahead of it itself there (`rt::queue`).
- `dispatch_release` of a source's last reference cancels it (`_dispatch_source_xref_dispose`): pending data is dropped, and the cancel callout frees the handler on the target, with no `dispatch_source_cancel` called. A model whose release leaves the source live delivers merges libdispatch never delivers. `rt::signal::CoalescingSignal` cancels at its last release.
- An exception costs time the guest can see. In an arm64 process the first `@throw`/`@catch` costs about 25 µs (the unwinder's first use), later ones about 5 to 8 µs, and a `%@` of the object a few more; a Rust `Result` costs about 1 µs. In `interplay_limits_high_children_circular[isolate]` the cheaper path let the guest see child 9's "Circular wait" fault before the asynchronous fault-mask set landed (`0x102c` read 0 where the slower path's read gives 1). Measured from the doorbell write's return to the fault's visibility, 16 runs each: 91-207 µs (median 106) with a real exception at each raise, 47-352 µs (median 81) with `Result`s alone. A raise here is a value, with no exception thrown (architecture 6.2). When a suite difference depends on how soon something becomes visible after an error, measure the error path's latency, not just its effects.
- A fixed-width model of an unbounded stack fails silently at depth. A catch-scope stack that kept "is the innermost scope a foreign boundary?" as a 64-bit register, shifted on each scope entry, lost the boundary's bit when a resolver's lookup recursed through more than 64 nested scopes, and a throw there made a round trip it should not have. Keep, per scope, the value it replaced and restore it on exit, which is exact at any depth, and test past the width (70 nested scopes).
- Work done only for a log line belongs inside the line's gate. Reading an exception's `callStackReturnAddresses` eagerly at every caught Metal raise was work only a line printing `callStackSymbols` needs, and it cost time on the guest's error path. A `log` macro evaluates its arguments only when a logger takes the line; a read with an effect the guest can see (guest memory, which can die) goes before the line instead, so it happens whether logging is on or off (architecture 14).
- A `dispatch_data_create` destructor is behaviour: a destructor block with a NULL queue runs on a `com.apple.root.default-qos` worker after the release returns, while `DISPATCH_DATA_DESTRUCTOR_DEFAULT` makes a copy that the releaser frees inline.
- A retaining pointer's assignment releases before it retains. Apple's framework assigns its retaining pointers by doing nothing when the new pointer is the one held, and otherwise releasing the old one before retaining the new one. Where that release crosses the API, compare the handles' identities, drop the old handle, then store the new one's reference: `*slot = Some(new.clone_ref())` takes the new reference first.
- A check every thread makes must not touch a `thread_local!` whose value has a destructor. Reading the isolated task's trap (a `RefCell<Option<Arc<_>>>`) before every Metal send and guest write, on every thread, made the C API's display tests die with SIGSEGV within milliseconds in 7 of 10 crate runs, and never under a debugger; reading a destructor-free `Cell<bool>` first, and the trap only on a thread that runs a task's code, gave 0 in 12 (`tasks::isolation::life`, since deleted with the paravirt device). The likely route is the destructor's registration on a thread's first access, made while that thread already destroys its thread-locals. When a test segfaults at once and only now and then, look for a thread-local that a change made every thread touch.
- A Metal call's output can change with the host's boot, which no host key captures. Apple's private `-fillTexture:level:slice:region:color:pixelFormat:` on a texture of pixel format 550 (a two-plane XR10 format the public headers do not name) writes texels that change at every reboot and are the same in every run within one: what the guest read of them after the library's page-out was `84307cca`, `84b0e5c9` and `843027c0` across three boots (**measured**), sharing their low 15 bits and the top two, which the page-out kernel sets. Cases that dumped those texels failed after each reboot on every build alike. Their fills now sit outside the dumps, and a copy from another 550 texture writes the dumped texels. When cases fail at once on every build after a reboot, run them at an older commit before bisecting, and check whether what they dump is the platform's own output rather than the library's.
- A Metal answer can be bytes Metal never wrote, and those hold what the calling code left. Apple's private `-fillTexture:level:slice:region:color:pixelFormat:`, given a pixel format it packs no colour in, fills the 16 bytes of the calling thread's stack where its packing writes a colour in a format it packs. A test recorded them on 2026-10-23 as the bytes of the colour fill before it, which had left them there, and the runtime's hold of that texel across encoders was built to match; on 2026-11-07 the same test, on the same macOS build, read `80 ef 0b 82 02 00 00 00 42 a2 3d fe 01 00 00 00`, the encoder's class and the selector as pointers, which objc2's check of the method before each send in a dev build had left in those bytes (**measured** on the M3 Max, macOS 27.0.1: the bytes are those two addresses; the same fills sent by `objc_msgSend` itself read the earlier fill's bytes, and after a call that set the stack below to one byte, that byte). Metal had not changed (the same build): the check's frames had moved (not bisected; the toolchain moved to nightly-2026-11-03 between the two). How to spot the next one: an answer that holds a value no input gave, or one that changes with the build, the boot or the calling code while its inputs stay put. Set the stack below the call to a byte of your choosing and see whether the answer follows; a test of such a call sends it by `objc_msgSend` itself, with no call between it and what it depends on (`gpu::fill`'s `metals_leftover`). Sent so, the process's first pair still read other bytes, the selector's address and a heap address, while every later pair read the earlier fill's (**measured** the same day, the first of four pairs in one process; which first-send work leaves them is not established), so the test failed in every run, each test being a process of its own under nextest: a measurement of what the stack holds sends one pair first and compares from the second, as a guest's long-lived process sees it.
- A test that frees memory and then expects its address to be unmapped races every other test thread in the process: `mach_vm_allocate` anywhere hands the page straight back out. Recheck the region when the unexpected happens, and retry with a fresh page.
- A test on a virtual clock waits for good at the first wait of anything real it reaches. The C API's video device tests ran on core's testkit platform, and making the device opened the host's backend on that platform's clock: on a host with VA-API, its JPEG decoder's trial run at the opening waited for the GPU through a poll whose pauses are timed waits on that clock, which no test advances, and the tests sat in futex waits at no CPU until nextest ended them. A Mac, whose VideoToolbox waits for nothing as it opens, passed them, so only a Linux run showed it. A device a unit test makes on the testkit platform opens no hardware there: it is made on a stand-in (`VideoDevice::without_backend`, `ScalerDevice::with_backend`), or what opens the host's hardware gets std's runtime. The next one shows as a test that ends on one host and, on another, sits under `VirtualClock::wait_until` at no CPU.
- A guest framework sends members of Metal's private protocols to the bundle's objects without asking. Metal's own objects adopt an SPI protocol beside each public one (`MTLLibrarySPI` beside `MTLLibrary`, ...), and the frameworks built over them call its members unchecked: macOS 13.7.8's Maps sent `newFunctionWithName:constantValues:pipelineLibrary:error:` to a library of the bundle, which adopted only `MTLLibrary`, and died of the unrecognized selector at launch. A check that walks only the public protocols misses the whole class, and an app pass shows only its first member, as a crash. The register's check now walks each class's SPI counterparts and the members older releases' protocols carry (`guest/bundle/tests/protocol_members_tests.mm`), and every class of the bundle logs a selector it does not recognize before it raises (`RGFX: unrecognized:`), so one boot shows each member a framework sends.
- A registry path one object publishes for another goes stale when a name in it changes. The kext's framebuffer named its accelerator in `IOAccelTypes` by the PCI device's path as it started, and the accelerator renamed the device `GFX0` after that, so the path led nowhere: `IOAccelFindAccelerator` failed for our framebuffer in every process, and on macOS 11 a process with no WindowServer connection, which takes its OpenGL renderers from each framebuffer's accelerator, was offered the software renderer alone, while WindowServer's own processes saw nothing wrong. Spot it by following each published path with `IORegistryEntryFromPath` after boot, not as it is set; the accelerator now names itself again as it finds the framebuffer (`guest/kext/src/RgfxAccelTypes.hpp`).
## The Vulkan platform
- A Metal comparison run after MoltenVK has worked on Metal's device, in the same process, sees Metal let go late. A test of texture ID reuse that ran the Vulkan platform's sequence first and Metal's second found Metal's texture, released while a command buffer held it, still held when `waitUntilCompleted` returned, in 3 runs of 3. Metal run alone frees it by the time the wait returns (5 runs of 5), and 300 ms after the wait it was free in both runs that waited (**measured** on the M3 Max). Metal lets go of a command buffer's resources asynchronously, and once MoltenVK's work shares its device, that release loses the race with the waiter; it looks like the runtime freeing IDs too early. Run Metal's side of a comparison first, before the Vulkan platform makes anything in the process, wherever what is compared depends on when Metal lets go of something (IDs, addresses, retain and use counts, reuse): `texture_identifiers_are_reused_as_metals`, `a_command_buffer_holds_a_surface_as_metals_does` and `holds_as_metals` do. When Metal's side of a comparison disagrees with a plain-Metal probe of the same sequence, run it again with Metal's side alone in its process.
- A rule that covers a list of shapes is only as whole as its list, and the list must come from every scenario that makes one, not from the cases the change already knows. A death at a depth or stencil texture whose size Metal's was not measured for exempted the shape of the two cases it named, a 2D `Depth32Float_Stencil8` texture of two levels, and missed the `Depth32Float_Stencil8` cube arrays and an `X32_Stencil8` texture other scenarios make: the full suite died in all three, in every setup, where the change's own check had run a subset picked by name. Unit tests could not show it either: only the guest's serialized descriptors turn `allowGPUOptimizedContents` off. The scenarios build without a device, so the list can be exact: build every one with its descriptor builders wrapped, and list each descriptor of the formats in question with the scenarios whose ops carry its bytes. How to spot the next one: a new death at a creation call, checked by a suite subset rather than the full suite.
- A copy of raw bytes carries the layout of every object over them. Core pages a legacy heap's bytes to and from the guest's pages through its buffer over all of the heap, so the guest's pages hold, and a texture of the heap reads after a page-in, whatever layout the platform keeps there. On the Vulkan platform that was the driver's: a native driver's own tiling, or on MoltenVK Metal's layout of MoltenVK's texture, whose usage can differ from the guest's and with it whether Metal compresses the texture (**measured**, `legacy_heap_textures_are_metals_where_metal_keeps_them_plain`). Nothing died or announced it, and no test or suite case read a heap's bytes over a texture. How to spot the next one: for any path that copies an object's bytes whole (paging, a buffer over a heap, an alias of the same memory), list every object that shares those bytes and ask whose layout each one's bytes are in.
- A device test that builds its objects another way than core builds them checks another flow than the one the guest drives. Tests of objects over the guest's pages under a heap's texture (`gpu::over_pages`, a registry since deleted) made their heaps over the guest's pages at once, where core makes a detached heap over memory of its own, places the guest's textures in it, and gives it the guest's pages only at its first prepare, by a replace (`resources/heap/detach.rs`): in core's flow every check compared the guest's pages with core's temporary allocation. The same test replaced a buffer without the detach core makes first, which Metal refuses, so it died at its first line on its first GPU run and had never reached its assertions. Followed through core's flow, the registry never fired at all: core makes each detached heap's cover, its buffer over all of the heap, first and never releases it, so every texture the registry kept apart died at its placement beside the cover first, and the registry, which every command paid a check for, was deleted. Make test objects as core does (`detached_heap`, `replace_heap` in `gpu::resource`'s tests), ask of a check whether core's flow can reach it at all, and for a check of where an object lies, ask what changes where it lies after it is made: a replace, a detach, a discard.
- A sweep shows a rule only where it holds an input on which two rules part. The colour fill packer (`crate::gpu::fill`) was compared with Metal over thousands of colours, but its NaNs were only `f64::NAN` and `-f64::NAN`, and no double lay strictly between two integer edges, so three of Metal's rules went unmeasured and the packer missed all three: a signalling NaN into an integer channel stores the largest value, a NaN's payload survives into a half or float channel, and an `R32Uint` double strictly between 2^31 - 1 and 2^31 stores 2^31. How to spot the next one: a sweep of an encoding whose NaNs are all default quiet NaNs, or whose edge values are all exact integers; it must also hold signalling NaNs, payload bits at the positions each target format keeps and drops, and values strictly between representable edges.
- An option of a release can move what the release does first. Without a keep-alive, the runtime frees a no-copy buffer's import and then runs the deallocator; given one (its D822), it runs the deallocator first, at Metal's moment, frees the import, and only then drops the keep-alive. A keep-alive holding nothing would have moved every unmap a deallocator of core's makes before the free, on every release, and a driver that validates host-pointer imports at each submission fails on unmapped pages. The platform gives the keep-alive what must outlive the import: the aliases and twins it imports, and a hold that makes core's unmaps through `VulkanVm` wait for the free (`reims-vgpu-vulkan`'s `remap`). How to spot the next one: when a dependency adds an argument that changes when a callback runs, read the code that runs it for the order of everything else it does, not just the callback's moment.
- A copy of a Vulkan handle keeps nothing alive. Shared shader modules each held a clone of `ash::Device`, a table of function pointers around a raw handle, which a review passed as harmless; a module released after the device's teardown then destroyed itself through the dead device, and runs on a software rasterizer (llvmpipe) crashed every time. A raw `VkRenderPass` copied into a pool's closure was the same slip. How to spot the next one: in a change that shares or caches a Vulkan object, or moves one into a closure, list every holder and check that each ends before the device and the loader do.
- A record's flag is not the Metal storage mode of the same name. A detach buffer's or heap's private bit (record flag bit 0) reads as Metal's `Private` storage, which the guest's CPU never reaches, and is not: core makes those objects `Shared` over the guest's pages, and the contract makes them the pages themselves ([testing.md](testing.md), the detach column of its table of private buffers and heaps: guest rewrites made while attached reach later GPU reads, `interplay_lifetime_pause_resident`; the GPU's fills are in the pages at once, `interplay_lifetime_heap_alias_buffers`; two tasks' private buffers over one page both keep their fills, `interplay_memlive_alias_writeback_race`). Copies of those objects in a discrete GPU's own memory, moved only at replace, detach and suspend, made them the legacy host copies that column rules out, and wrote whole objects back into pages the guest may have moved on from. In the first boot with them on an RTX 5080 Laptop GPU, the guest's WindowServer aborted 26 s after it started, on a corrupted malloc free list, and the session never logged in ([video/bugs.md](video/bugs.md), B26). The suite could not show it: it ran on the Mac's Metal platform then, and the copies existed only on Linux discrete GPUs. Before a change keeps a guest object's bytes anywhere but the guest's pages, read that object's rows in testing.md's tables, not its flags' names.
- A process exits while its other threads run. The exit runs the exit handlers and the loaded libraries' destructors on the exiting thread, in the reverse order of their registration, and every other thread goes on meanwhile: one inside a GPU driver as the driver's destructors free its state ends the process, after its tests passed or as QEMU quits. Seen on the RTX 5080 Laptop GPU (NVIDIA 615.71.09): the awake thread's touches segfaulted 79 times in a six-minute run of the workspace's tests, and test processes ended with `SIGSEGV` inside `libnvidia-glvkspirv.so`, the driver's SPIR-V compiler, after "ok": the scaler device's test (the scaler since deleted) in 2 of 3 full-workspace runs, its devices in statics never dropped and its make-ahead thread joined by nothing, and a device test of pin 22 under load, its device in a static. A static that holds a device, or a thread nothing joins, is the shape; dropping every static device is not possible (the platform keeps its devices for the process), so the library's threads take each job that may call a driver as a step of the exit gate (`reims_vgpu_vulkan::exit_gate`), whose exit handler, registered after the driver loaded and again after each making, waits for the steps in progress and parks every thread that takes the next. The runtime's guard covers the runtime's own threads alone (`rt::process_exiting`). How to spot the next one: a `SIGSEGV` or `SIGABRT` after a test's "ok", or at a quit, on a thread inside a driver's library, with the exiting thread in `__run_exit_handlers` or `_dl_fini`; a new thread of the library's whose jobs call a driver outside `entry::run`, a window's frame, the video runtime's `exit_step` or the gate's own steps is the next case of the class. Two more shapes of it, seen on the Iris Xe (intel-media-driver 26.3.5) as `vaTerminate` aborting in iHD's frees after "ok" in 2 of 90 full-workspace runs: a driver loaded after the gate's last registration, as `vaInitialize` loads a VA display's, registers destructors that run before the gate's handler, so the handler must be registered again after every such load (`Runtime::arm_exit`); and a call a crate makes at once on its caller's thread, as the VA crate's `Calls` makes a release where its call thread is idle, is a job too, and needs its own step. With both, 60 full-workspace runs under glibc's malloc checks ended with no failure at exit, where the code before them had 2 in 100 such runs (an abort in iHD's frees, and a `SIGSEGV` whose stack was not caught); a program of its own that calls `vaTerminate` after iHD's destructors ran, its display holding nothing, ends cleanly in 400 runs, so the abort needs a display with live decode state at the terminate.
## QEMU, the window and VM boots
- An answer the newest Metal knows can be one an older Metal has no table for. The device answered the M3 Max's feature profile, 10, which 13.7.8, 14.8.9 and 26.7.2 create the device with; macOS 12's Metal keys every limit of a device on that profile, has none for 10, and left them 0, so WindowServer ended at device creation with a failed assertion that a limit be above 0 (`-[_MTLDevice initLimits]`), launchd gave up after 14 runs and the guest never reached its desktop. Unit tests and the boots of 14 and 26 passed throughout. The device now answers by what the guest's Metal has (`guest/bundle/src/RgfxFeatureProfile.hpp`). How to spot the next one: WindowServer crashing on `com.Metal.DeviceDispatch` under `MTLAddDevice` on one release and not the next; boot the oldest release of each answer's range, not only the newest.
- A device-info answer chooses the guest's code, not only a value it reads. Answering Metal's SIMD bits of key 33 on the Vulkan platform, where they had followed the device, made hundreds more suite cases match Metal's, and a macOS 15.6.1 guest then died at boot: with the bits set, its frameworks chose a SIMD blur whose tile dispatch the runtime refuses, where before they took a fallback and booted. With that fixed, a 26.6.2 guest died at the next refusal down the same path, a sampler that path makes and the other never did. The suite's scenarios do not model the guest's choice, and guest shaders are never committed, so only a boot shows it. How to spot the next one: a change to what device info, GPU families or feature queries answer; boot the guests on it before it merges, and keep the old answer until they boot (AGENTS.md, "Checking a change").
- A difference a boot already logs is a death on every boot once it is made one. A change that ended the process on two differences the Vulkan platform had logged passed `cargo xtask check`, and every macOS 26 boot then died early, at about 6 s on MoltenVK and 38 s on an NVIDIA driver, each at one of the two: the last good boot's log had counted 873 states with one and 20 with the other. No committed test runs the shaders a guest's boot draws. How to spot the next one: before a change ends the process on something the platform logged, look its code up in the last good boot's notice counts; any count there is a death every boot reaches.
- A hop to another thread that the caller waits for is a wakeup the caller depends on. `apple-gfx` made each MMIO access on a thread of its `ThreadPool` while the vCPU waited in `AIO_WAIT_WHILE`, holding the BQL, for the job to set `completed` and call `aio_wait_kick`. One vmapple boot hung 3 million accesses in, at a doorbell write: the access had completed and no thread was in the library, yet the vCPU slept in `aio_poll`'s `select` for good, and QEMU's main loop, its UI and the other vCPUs waited for the BQL it held. The wakeup was lost somewhere between the pool's job, `aio_wait_kick`'s BH and the event notifier, and no stress test of the pattern reproduced it. The hop bought nothing, since an access waits only on the library's threads, which never wait on QEMU, so QEMU called the library on the vCPU's thread from then on, as the reims-graphics device's MMIO handlers do. Before a host waits for its own job on another thread, ask what the job waits on: when it is nothing of the host's, call it directly. When a sampled thread sleeps in a poll inside a wait loop and no thread runs the job it waits for, suspect a lost wakeup, not a slow job.
- A build that reads a pkg-config package at configure keeps what it read. meson reads `reims-vgpu.pc` when QEMU is configured and keeps its flags, `Libs.private` among them, in its build files; a change to the package does not make it configure again. When the library came to need Carbon (the window's ISO keyboard check), a QEMU build configured before that linked the new `libreims_vgpu.a` with the old framework list and failed on two Carbon symbols. Neither `cargo xtask check` nor the suite links QEMU, and the smoke reads the package at each link. `make qemu` keeps a copy of the package it configured with (`build/qemu/reims-vgpu.pc.configured`) and configures again when the dist tree's differs. When a host that links the archive fails on a system framework's symbols after a library change, compare the dist tree's `Libs.private` with the flags the host's build recorded (for QEMU, the link line in `build/qemu/build.ninja`) before looking at the code.
- An activity against App Nap can keep the host awake. `NSActivityUserInitiated` includes `NSActivityIdleSystemSleepDisabled`: the window's activity, begun with it for the process's life, kept the host from idle sleep for as long as QEMU ran. `NSActivityUserInitiatedAllowingIdleSystemSleep` keeps App Nap away and leaves sleep to the host's own settings (`reims-vgpu-window/src/native/macos/app.rs`). No test can see it: when a Mac stops sleeping while the library runs, read `pmset -g assertions` for the process first.
- A VM's timings depend on whether the person at the host sees QEMU's window. Under `-display cocoa`, macOS napped QEMU 30 to 50 s after it lost the focus: every QEMU thread (the vCPUs and the library's FIFO and display threads among them) ran at priority 4, and Metal's compiler service ran QEMU's compiles at 0 to 4. A 26.6.2 guest booted that way reached its desktop at 215 s, and at 53 s when QEMU was kept in front (**measured**); it looked like slow compiles and shader caches. The library's window holds an activity against App Nap for the process's life (`reims-vgpu-window/src/native/macos/app.rs`). Before trusting a boot's timings, read the host log's `Set AppNap state` lines for QEMU's pid (`log show --predicate 'process == "runningboardd" AND eventMessage CONTAINS ":<pid>]"'`): `active:Y` begins a napped stretch, and the next focus (`SETFRONT: pid=<pid>`) ends it. Or sample its threads' priorities with libproc's `PROC_PIDTHREADINFO`: a QEMU whose named threads all sit at 4 is napped.
- A system value that names the device last used is read at each use. HIToolbox's keyboard type (`LMGetKbdType`) follows the keyboard last typed on: the window read it once, when it opened, so a keyboard of the other layout plugged in afterwards (ISO in place of ANSI, or the reverse) swapped the key left of 1 with the key right of left Shift in the guest. `InputState` asks again at each key event (the window crate's `native::is_iso_keyboard`). When input maps right on one keyboard and wrong on another, look for a value read once that names a device.
- A value the host sends is not the value the guest decides by. A display matching a Retina host screen was told 144 ppi and a scale factor of 2, and the macOS 13.6 guest still booted to a 1× desktop: it ignores the scale factor for its default, reads the size in millimetres as whole centimetres rounded up (611.04 mm is 62 cm), so it saw 141.6 ppi, below its HiDPI threshold (`reims-vgpu-window`'s `policy`). Unit tests of the policy passed throughout, since they checked what was sent. When a guest-visible choice misses, boot the guest and read what it made of the values (`ioreg`'s `DisplayAttributes`, `/Library/Preferences/com.apple.windowserver.displays.plist`), from a fresh clone, since the guest keeps its display settings per display.
- A threshold measured in the units the library tells is not the guest's rule when the guest reads them in coarser units. The window predicted a macOS guest's HiDPI default as "more than 143 ppi across the told millimetres", but the guest rounds the told width to whole millimetres and then up to whole centimetres, and switches between 146.666 and 146.667 ppi across that: `2560x1600@146` reads 45 cm, 144.5 ppi, and ran 1× while the window sized itself for 2×. Nor was it one rule: 1280 pixels wide stayed 1× at 216.7 ppi, and 5832 wide ran HiDPI at 128.8 (`reims-vgpu-window`'s `policy`). Measure a guest's threshold with inputs that land near it in the guest's own units (here, pixels across whole centimetres, chosen by width and density), split the rounding models with a value between them (440.39 mm, which reads 44 cm only when rounded to whole millimetres first), and vary the width to learn whether one number decides it.
- A snapshot of the guest's page tables shows the processes that happen to be on the CPUs. The probe that read a macOS guest's PTEs over BAR 2 through QMP walks each vCPU's current CR3 at one instant, and it found every user page there uncached (the guest PAT's UC-) in every arm, the same 1010 pages each time, while the bench encoding into write-combined spans ran: the bench was not on a CPU at that instant, and the pages were another process's. A reading of xnu's fault path that missed its block-map path for physically contiguous objects (`vm_fault`'s `pmap_map_block_addr`, which maps in the object's own cache mode) seemed to agree, and the write-combined spans were reverted and restored the same day: with them draws.10k encoded in 1.05-1.3 ms on the Radeon 780M host, without them in 7.7 ms (**measured**, 2026-11-07). How to spot the next one: before a page-table snapshot rules out a mapping, check that the snapshot holds the process that makes it (its CR3, or the same pages in it in the arm that should differ), and trust the A/B of the figure the mapping is for over a reading of the kernel.
- A guest-side command under `timeout` never runs on macOS, and the harness reads the miss as a timeout. macOS has no `timeout(1)` (it is GNU coreutils'), so a copy of a boot harness that ran `timeout 30 kmutil showloaded` in the guest over SSH got the shell's "command not found" (status 127) and reported "kexts: FAIL: kmutil timed out" on every release from 11.7.10 to 26.7.2. It looked like the harness it was copied from, whose kext check had failed on a real wait (the guest's first `sudo` held kmutil's start for about 155 s, measured with a polled background job), so it was waived as that known fault for a day of boots; run as `perl -e 'alarm 30; exec @ARGV' kmutil showloaded`, it listed the loaded kexts at once (**measured**, 2026-11-08, 11.7.11 on llvmpipe). Bound a command in a macOS guest with `perl -e 'alarm N; exec @ARGV'`, or on the host side of the SSH. How to spot the next one: a check that fails the same way on every guest release, whose command goes through `timeout` on the guest's side; run the command bare once and read its status.
- A VM made from an existing disk is a new Mac to its macOS when its OpenCore image presents a new UUID, and that new Mac does not shut down. `reims-ctl create --disk` with no image made one presenting a Mac of its own, and every `reims-ctl stop` of a macOS 26.7.2 disk waited out its 180 s and powered the VM off, since Setup Assistant (`-MiniBuddyYes`) was up from about 10 s after boot and it ignores Control-Option-Command-Power and the power button. Our kexts kept answering throughout, so it looked like a guest hang. The disk's user preferences held `com.apple.loginwindow` `MiniBuddyLaunch` = 1 for any host and 0 in the ByHost file of the Mac it ran on. ByHost files are keyed by `IOPlatformUUID`, which is OpenCore's `SystemUUID`, and the new UUID had none, so loginwindow took the any-host 1. Presenting the disk's own Mac, read from the image beside it, the stop shut the guest down in 9 s (**measured**, 2026-11-08, Radeon 780M host; `create.rs`, `disks_mac`). A copy of the disk of a VM reims-ctl has still gets a Mac of its own, since it can run beside that VM and two VMs presenting one serial number, MLB and ROM would be one Mac to Apple's services. What remains: a stop still powers off at its timeout whenever Setup Assistant is up, as on a new install's first boot until it is finished, on a disk with no image beside it, on such a copy, and with MiniBuddy's panes after some updates (`scripts/internal/guest-minibuddy-off.sh`). Nothing the host can send without the guest's password ends it. The keys and the ACPI power button (QMP's `system_powerdown`) both went unanswered for the whole 180 s. QMP's other power requests (`system_reset`, `quit`) are a power-off, and a macOS guest runs no guest agent. Only `sudo shutdown -h now` inside the guest shut it down, in 6 s (**measured** 2026-11-07). How to spot the next one: a guest that ignores a shutdown request; read `ioreg -rd1 -c IOPlatformExpertDevice`'s UUID against the UUIDs in `~/Library/Preferences/ByHost`, and look for `Setup Assistant -MiniBuddyYes` in `ps`.
- Host GPU work on a present's path that fits a refresh under load can miss it at a low frame rate. The present's answer waited for the window's draw of it, and on an RTX 5080 Laptop GPU the guest's 30-frames-a-second probe saw every frame a refresh late (2.7 refreshes from commit to presentedTime at 120 Hz, against 1.6 at 60 Hz on a 780M), while in its uncapped run each present was answered at the first refresh after its show: between frames the GPU clocks down, and WindowServer's composite took 4.4 ms of its time and the window's draw 4.9 ms, against 0.5 ms each at 120 frames a second (**measured** 2026-11-08, macOS 26.6.1, 3840 x 2400). The answer now comes at the refresh after the show (`graphics::present`). How to spot the next one: measure a present path's latency at a capped low rate as well as uncapped, and look at the host's per-present timing lines (`reims_vgpu::graphics::present_timing` at debug) for the step whose time grows as the rate falls.
- A guest framework can look for the GPU by what a Mac's GPU states and give up silently where ours states otherwise. On a macOS 11.7.11 guest, Safari 14.1.3 said only "Could not create a WebGL context.": OpenGL drew in a plain process and in one with no WindowServer connection, and no sandbox denial was logged. WebKit's ANGLE, which runs Safari's WebGL on OpenGL there, refused to start ("Unable to query ANGLE's SystemInfo.", read through `EGL_KHR_debug` by calling the guest's WebCore's own `EGL_*` exports from a probe): it found no GPU, since our PCI device's `class-code` read 0x038000, where both GPUs of an Intel Mac state 0x030000 (**measured**, macOS 26.7.1). With the kext stating 0x030000 on the PCI device's registry entry (`guest/kext/src/RgfxPciClass.hpp`), ANGLE started and Safari made its context (**measured**, 2026-11-08). How to spot the next one: when a guest feature fails with no log of ours and no denial, run the framework's own entry points in a probe with its debug output on, and compare what the guest's registry states for our GPU (`ioreg -l` on the PCI device and the accelerator) with an x86 Mac's.
- The system's LLVM exports a different C API on each release. The bundle's GL lowering takes the GL code generator's module through GPUCompiler's `libLLVM.dylib`, and asked for `LLVMGlobalGetValueType` along with the rest; GPUCompiler 31001, on macOS 11.7.11, 12.7.6 and 13.7.8, does not export it, so every GL shader variant was refused there ("a GL shader variant was not made: the system's LLVM has no LLVMGlobalGetValueType"), and AppleMetalOpenGLRenderer fell back to software processing that drew nothing: a GL triangle left the clear color, and Safari's WebGL canvas on 11 stayed its clear color (**measured**, 2026-11-08). The build Mac's and 26's GPUCompiler 32023 export it, so the bundle's tests on the build Mac never met it. The lowering now takes a function's type from its pointer's pointee where the call is missing (`RgfxGLLowering.cpp`'s `functionType`). How to spot the next one: an `RGFX: ... the system's LLVM has no ...` line on an older guest; before calling a symbol of the system's LLVM, list which releases' GPUCompiler export it (a probe that `dlsym`s each one in the guest).
- In an A/B of two boots in one job, the boot that runs first can stall far more than the second, whatever it runs, and the order alone can pass for a gain. A scroll A/B of two metal2vulkan pins on the 780M ran the old pin first and the new one second: vkQueueSubmit calls of 8 ms or more fell from 22 to 1, which read as the new pin's gain. The same two arms in the reverse order gave 20 and 1. The first boot, the one after a build or a perf run's post-processing on the same host, had the stalls, and the second had almost none, whichever pin it ran; an earlier A/B of two other pins in one order had shown 13 against 4. Lost frames followed the order as well (41 and 59 for the first boots, 37 and 41 for the second). How to spot the next one: a difference that an A/B shows in one order only. Run the arms in alternating order (A B B A) after a warm-up boot whose numbers are discarded, and compare boots in like positions.
- Synthetic input at the display's rate, on the clock the refresh grid runs on, keeps one offset into the refresh for the whole run, and an offset at the frame's edge halves the frame rate. The boot harness turned the wheel 60 times a second on the host's monotonic clock, as the refresh thread ticks, so each scroll run's clicks fell at the same point of every refresh for all 15 s, a point set by when the run happened to start. Of 8 runs on the 780M whose clicks fell between 1.7 ms before a refresh and 1 ms after it, 6 had 1.6 to 6 s of WindowServer compositing at every other refresh, with every present answered on time and Safari's page reporting 60 frames a second; of 23 runs at 1.3 to 15 ms after a refresh, none had more than 0.43 s. Started at chosen offsets (10403), 0.3 ms and 15.2 ms gave 3.5 to 6.1 s of it each and 112 to 192 frames lost, and 9 ms gave none and 2 to 29 frames lost. Across runs it read as a device stall that came and went. How to spot the next one: a loss that a run has either for seconds or not at all, with nothing on the host changing at its start. Measure where the input falls in the refresh (the present_timing lines give the grid), and start periodic input at a set offset mid-frame.
## Tools and worktrees
- A shell script under `set -u` with an EXIT trap passes when it aborts, on macOS. **Measured** with macOS's `/bin/bash`, 3.2.57, 2026-11-08: a script that reads an unset variable under `set -u` stops there and exits 1, but with any `trap ... EXIT` set it exits 0, and `$?` is 0 inside the trap too, so even a trap that exits with the status it saw passes it on. `guest/rgfxgate/tests/payload_test.sh` removed its scratch from such a trap, and a case that read a shifted-away argument stopped the script at its first bundle while `make -C guest test` went on green. Each script that pairs them now keeps an `ended` flag, set at each deliberate success end, and its trap turns an exit 0 short of that end into 1 and keeps any other status: `trap 'rc=$?; CLEANUP; [[ $rc != 0 || $ended == 1 ]] || rc=1; exit $rc' EXIT` (an `exit 1` from the trap does set the status after such an abort). How to spot the next one: a check that reports green with less output than it should, its last lines missing; look for `set -u` (or `set -euo pipefail`) beside `trap ... EXIT` in a script that runs on a Mac, and give it the flag.
- `git stash` is one list, shared by every worktree of a repository (`refs/stash` is not per worktree), so a stash pushed in one worktree can be popped into another. Set work aside with a WIP commit on the worktree's own branch, or a patch file under `/tmp`, never a stash. When changes appear that nobody in the tree made, or a pop conflicts with files the tree never touched, suspect another worktree's stash.
- A shared `CARGO_TARGET_DIR` runs another tree's `xtask`. Cargo keys a workspace member's build by its path inside the workspace, not by where the workspace is, and calls the binary fresh when no source file at those relative paths is newer than its last build. So a worktree whose files predate the other tree's last build of `xtask` runs that build, made from the other tree's sources (**measured** on two copies of one package sharing a target directory: the second `cargo run -v` printed `Fresh` and ran the first copy's binary). Give each worktree its own target directory under `~/.cache`. When a tool behaves as if a change were missing, look for `Fresh` in `cargo run -v`.
- An archived tree's files carry their commit's time, so cargo can take a dependency's new sources for its old build. `git archive` stamps each file with the commit's time and `tar -x` keeps it, and `rsync -a` keeps the source's times; cargo calls a path dependency fresh when none of its source files is newer than its last build. Exporting a newer metal2vulkan commit over a tree built after that commit's date left the runtime `Fresh`: one cargo command reported a new item missing while another, which rebuilt, compiled it. After every extract, stamp the files with the time of extraction (`tar -xm`, or `find <dir> -type f -exec touch {} +`), and check that the next build's log shows `Compiling metal2vulkan`. When one cargo command sees a dependency's new item and another does not, or `cargo build -v` prints `Fresh` for a dependency whose sources just changed, look at the sources' times.
- rustc's incremental state can fail a build that is sound. After an edit to `reims-vgpu-vulkan`, an incremental `cargo clippy --workspace --all-targets --all-features` failed in `reims-vgpu` with E0275, an overflow evaluating `metal2vulkan_runtime::heap::HeapShared: Send` for the window's Vulkan sink, whose auto-trait walk through the runtime's types runs near the recursion limit, or with an internal compiler error, "encountered incremental compilation error with evaluate_obligation". The incremental cache keeps the result of one order of that walk, and the edited crate's build takes another; a comment appended to a file of the crate reproduces it, and a build of `reims-vgpu` from nothing passes, as does one with `CARGO_INCREMENTAL=0`. The cure is `cargo clean -p reims-vgpu` before the check. How to spot the next one: an E0275 or an ICE naming `evaluate_obligation` in a crate the change did not touch, after an edit to a crate it depends on, that a clean build of that crate does not show.
- A submodule shared by several worktrees has one `core.worktree`. When a superproject worktree's `vendor/qemu` is a linked worktree of the main checkout's module repository (`.git/modules/vendor/qemu/worktrees/<name>`), `git submodule update` there writes that worktree's path into the module's config, which every worktree of it shares. From then on every git command in the main checkout's `vendor/qemu` acts on the other worktree's files: a fast-forward moves the main checkout's branch and writes the other directory, the main checkout's own files stay at the old commit, and `git status` and `git diff` report the other tree's state. `git -C vendor/qemu rev-parse --show-toplevel` must print the main checkout's `vendor/qemu`; restore it with `git config --file .git/modules/vendor/qemu/config core.worktree ../../../../vendor/qemu`, run from outside the submodule, since git reads the broken config before any flag. Give a worktree that builds QEMU its own clone of the submodule, or leave its submodule uninitialised, and remove a linked worktree of the module with `rm -rf` and `git worktree prune`, never `git worktree remove`. When a submodule's status contradicts its files (`git diff` shows a change `git hash-object` does not), suspect `core.worktree`.
- A test nextest calls leaky on macOS need leak nothing. nextest marks a test `LEAK` when its standard output or error is still open 100 ms after its process exits, which only another process holding the pipe can do. On macOS, std makes a child's pipes with `pipe()` and only then sets close-on-exec on them (`library/std/src/sys/pipe/unix.rs`: macOS has no `pipe2`), and nextest starts tests from several threads at once, so a test started in that window inherits the write end of the output of the test started beside it and holds it until it exits. **Measured** with cargo-nextest 0.9.140 on the M3 Max (macOS 27.0.1), with a probe whose tests only read their own descriptors and sleep: 14 of 1,440 test processes started holding a pipe's write end without `FD_CLOEXEC`, each that of a test started within 7 ms of it; with tests of 10 ms and 800 ms alternating, 3 of 720 short tests were reported leaky, each one whose output a long test started beside it held. reims-vgpu-graphics' device tests, which spawn nothing, were leaky in car 12's and car 13's checks (they start among the first, beside the long Vulkan tests), and so was a test of a pure function there (`device::backlog::tests::a_message_is_its_context_s_by_its_id_or_its_field`, 1 of 2,440 runs). A leak is a pass, and the test cannot prevent it. How to spot the next one: a `LEAK` on a test that starts no process, at random among tests started together; a test that leaves a child holding its output leaks in every run.
- nextest's `--stress-count` with `--no-fail-fast` exits with the last iteration's status only. **Measured** with cargo-nextest 0.9.140: a test that failed in iteration 1 of 3 and passed in 2 and 3 exited 0, under the summary `3/3 stress run iterations: 2 passed, 1 failed`; without `--no-fail-fast` the first failure stops the run and it exits 100. Count failures from the summary line, never from the exit code.
- kache shares nothing with a target directory built without it. kache keys a unit by the contents of its dependencies' outputs, and rustc under kache writes other bytes than rustc alone (kache remaps the build's paths), so in a target directory cloned from a build without kache every workspace crate's dependencies differ from those the store's entries were built on: each misses, compiles and is stored under a key no other tree uses. **Measured** on the M3 Max: a new worktree whose target directory was cloned from a seed built without kache missed all 72 of the workspace's units (the tests of `cargo xtask check`'s features, 410 s), where one with an empty target directory hit 11 of the workspace's 12 libraries and 119 of its 120 dependencies (170 to 232 s). Start a target directory empty, or from one built through kache. How to spot the next one: `kache explain CRATE` names `externs` among the key groups a workspace crate's miss differs in.
- kache serves a build script's recorded run to a build whose environment the script reads differently. kache keys a run by the script binary, the variables Cargo itself sets and the script's `rerun-if-*` declarations (kache 2.0.0, `src/build_script.rs`), and SDL's script declares none of the C flags or `MACOSX_DEPLOYMENT_TARGET` that `cargo xtask dist` gives it, so dist's SDL, built again after `cargo clean -p sdl3-sys`, came from a run of a plain build on the host: its globals stayed common and its objects were built for the SDK's macOS, and the archive check failed (**measured** on the M3 Max). dist now turns the build-script cache off for its build (`KACHE_BUILD_SCRIPT_CACHE=0`). How to spot the next one: a build step that changes a dependency's build through the environment alone (an `[env]` entry, a variable the script never declares) and then sees no change in its output.
- kache restores a macOS dylib with the install name of the target directory that first linked it. The linker names a dylib by its output path (`LC_ID_DYLIB`) where the link gives no `-install_name`, and rustc gives none by default (it does with `-C rpath`). kache keys the link by inputs that name no worktree, as it remaps the build's paths, and restores the bytes first linked, so the C API's cdylib in a new worktree named the worktree it was first linked in: the C harness, linked to it, recorded that path and failed to load once that worktree was removed, where a relink in a fresh worktree passed (a potluck job on the M3 Max). `crates/reims-vgpu-c/build.rs` links the cdylib as `@rpath/libreims_vgpu_c.dylib`, which the harness finds through its rpath, and `the_dylib_is_found_by_rpath` holds both. How to spot the next one: a load of a library built in a target directory that fails only after another worktree is removed, and `otool -D` on the library prints an absolute path.
- A link with LTO drops the standard library's `__isPlatformVersionAtLeast` from an executable. rustc links macOS binaries with no default libraries, so no compiler-rt; std's weak definition resolves the calls that C built for an older macOS makes for its `@available` checks, until LTO, which keeps only what Rust code reaches: `cargo nextest run --release` after `cargo xtask dist --release` in the same target directory failed to link SDL (built by dist for macOS 11.0) with the symbol undefined, where a dev build linked (**measured** with rustc 1.98.1 and 1.99.1). The window crate's build script links compiler-rt's builtins, unbundled. How to spot the next one: a native library that links in debug builds and not in release, its missing symbol one of compiler-rt's.
- `@available` in the guest bundle imports `fopen`, which the bundle's file check forbids. Clang lowers `@available(macOS N, *)` to a call to `__isPlatformVersionAtLeast`, which, from compiler-rt's `os_version_check`, falls back to reading `/System/Library/CoreServices/SystemVersion.plist` through `fopen` where the kernel does not answer the version; the symbol is linked whether or not that fallback ever runs. The Metal bundle every process loads, sandboxed ones among them, must import none of open(2)'s family (`guest/bundle/tests/bundle_files_check.sh`, part of `make -C guest test`), so a guard written with `@available` fails that check, at `-mmacosx-version-min=11.0` as at any deployment target (**measured**: the commit that read four newer descriptor fields under `@available` left `_fopen` undefined in the linked bundle, where the same reads under `respondsToSelector` left no open-family symbol). Read a field newer than the bundle's floor off an Apple descriptor or event through a runtime presence check, `respondsToSelector:` or the `spi()` helper, never `@available`. How to spot the next one: the bundle's own `nm -u` check (bundle_files_check.sh) names an open-family symbol after a guard is added; the fix is a presence check in place of the `@available`.
- A test that faults the GPU fails the tests beside it, and they pass alone. Every process on a Mac shares its GPU: a fault there is a GPU recovery, and each command buffer another process has in flight fails as its victim ("Discarded (victim of GPU error/recovery)", `kIOGPUCommandBufferCallbackErrorInnocentVictim`), WindowServer's among them. `client_direction`'s `metal_drops_small_blits_into_the_texture` faults it on purpose, 84 GPU events in its 1.8 s, and every `cargo xtask check` on the M3 Max failed 9 to 14 tests that ran beside it: the YCbCr sweeps, the extended-range blends (whose Metal side then read zeros), the in-flight detaches, `new_images` (**measured**, macOS 27.0.1). The behaviour-lock suite's runner, since deleted, had long run such scenarios alone (`exclusive=True`); nextest ran them with the rest. `.config/nextest.toml` then ran it first, with nothing else in flight: five runs of the check's tests after that (three of them whole checks) failed no GPU test, where two runs without it, beside them, failed 10 and 7. The check's "Insufficient Memory" failures (the unreached-tiles and dont-care-load tests) were not pinned to one test: the largest, `a_reservation_of_2_31_minus_1_is_metals`, holds 16 GiB for about a second (its peak footprint, six times any other's) and runs alone too. Both are now opt-in (`#[ignore]`), run only for a change to what they test: a GPU recovery fails the work of every process on the Mac, WindowServer's and the terminal's included, so a stress loop of the fault test restarted the GPU under the owner's desktop (macOS 27.0.1, M3 Max, 2026-11-05: WindowServer's command buffers took GPU address faults and the display was flushed to recover). How to find the next one: macOS logs each GPU event (`log show --predicate 'eventMessage CONTAINS "Handling GPU event"'`, from ReportCrashService) and each failed command buffer with its process (`eventMessage CONTAINS "Execution of the command buffer"`); run the tests one at a time (`-j1`) under a test runner that logs each test's pid and start (`CARGO_TARGET_<TRIPLE>_RUNNER`), and the test that started last before a burst of GPU events is the one that faults. `/usr/bin/time -l` as the runner gives each test's peak memory footprint, the GPU's memory included.
- A busy kernel holds work in flight for its time on the device, and for nothing else. The Vulkan crate's tests sized `spin.metal`'s rounds for the M3 Max, about 60 µs a round, which an RTX 5080 Laptop GPU runs in about 0.28 µs: `an_unmap_in_a_deallocator_waits_for_the_import`'s fixed 1,000 rounds held about 0.3 ms there. The paging discard tests sized theirs to half a second from one run of 2,000 rounds, which on the 5080 is mostly the run's submission and completion (2.2 ms, about 0.6 ms of it the kernel's), so they held about 130 ms; and the steps the hold had to cover, two imports of host memory, waited in NVIDIA's driver lock while the other test processes made their devices, for up to 455 ms, past any kernel a test may run (a ring held past 2 s resets on an amdgpu host). Under the crate's whole run the paging tests failed in 7 and 3 of 9 runs, and every one passed alone (**measured**, 2026-10-26, NVIDIA 615.71.09). `gpu::spin` now sizes the kernel from a timed run of 50 ms or more, and the paging tests run alone on Linux (`.config/nextest.toml`), each checking that its hold outlasted its reads and running again where it did not. How to spot the next one: a test that holds the GPU with a fixed count of rounds, or that reads what the runtime holds while a kernel runs, after a call that enters the driver.
- A header the library shares with the option ROM is one of the ROM's sources. `crates/reims-vgpu-graphics/include/reims_graphics_wire.h` is compiled into `firmware/prebuilt/ReimsGraphics.rom`, and the ROM's record, `firmware/prebuilt/ReimsGraphics.toml`, holds the header's sha256. A change that added a feature bit, a flag and a record to the wire for the GL renderer's private render state passed the library's checks, which build no firmware. It landed and left development failing reims-ctl's `cargo test` (`the_prebuilt_rom_is_built_from_the_trees_sources`) and `cargo xtask check`'s `make -C firmware prebuilt-check`. The ROM built again had the same bytes: only the record was stale. How to spot the next one: a diff that touches the wire header, or any other file the record names, runs `make -C firmware prebuilt` on a Mac in the same branch and commits the ROM and its record with it; `make -C firmware prebuilt-check` names each file that changed.
- A rebuild of `guest/prebuilt` from unchanged sources can still give different bytes, which looks like the change altered the kexts. Two inputs that are not sources decide them: the shell's locale, since the bundle links `src/*.mm` in the order the shell sorts them, and the day, since Lilu's `plugin_start.cpp` writes the build date into RgfxGate and the loader, changing their bytes and UUIDs. The crate rename that moved the wire header found it: its first rebuild, in an en_US locale on a later day, differed from the committed set, and so did a rebuild of the untouched tree. How to spot the next one: to show a change leaves the kexts byte-identical, rebuild with `LC_ALL=C` and `SOURCE_DATE_EPOCH` set to the committed kexts' build date, and compare that against the committed set, not a default-locale rebuild.
- The arm64e link of the guest bundle can give two binaries for one tree. ld (ld-27106.1) made two slots for `objc_msgSend` in the bundle's authenticated GOT, one for the message-send stubs (`__objc_stubs`) and one for `objc_msgSend`'s own call stub, and handed them out in either order from one link to the next: three clean builds of one tree on the M3 Max gave RgfxGate's arm64e binary as A, B, A, differing only in the bundle's arm64e image (its UUID, its signature, and the slot `__objc_stubs` loads). The arm64 image, whose GOT is not authenticated, was the same each time. It showed as a rebuild that changed RgfxGate though none of its sources had. The bundle's arm64e link now takes the small stubs (`-objc_stubs_small`, `guest/bundle/Makefile`), which branch to the call stub and take no slot. How to spot the next one: when a set's binary changes with no source of its own changed, build it again from the same tree two or three times before looking for an input; if the builds alternate, diff the two by section (`otool -l`, then the section's disassembly) and look for a choice the linker makes freely.
- A weak kernel import a kext's code reaches directly keeps the whole kext out of a kernel that lacks it. OpenCore's linker binds an unresolved weak import to 0, and a call or address relative to the instruction cannot reach 0, so it reports `RIP-relative overflow in <kext>: ... target=0x0` and leaves the kext out of the kernel collection (`[FAIL] ... injected - Invalid Parameter`): the guest boots with no display driver. **Measured** 2026-11-08 with OpenCore's TestKextInject: ReimsGraphics with a weak `IOMemoryDescriptor::getPageCounts(resident, dirty, swapped)`, which the 26.x kernels export and 11.7.11, 13.7.8 and 15.8.2 do not, was injected into 26.7.2's Boot KC and refused by the other three. Neither `make -C guest test` nor `prebuilt-check` links against a kernel, so both passed. How to spot the next one: a weak import is reached only through a word of data, whose whole address the linker binds (`guest/kext/src/RgfxAcceleratorLocks.cpp`), and any change to a kext's imports runs `make -C guest set-check` against the Boot KCs of the oldest and newest releases it supports.
- A reference decoder can be the one that is wrong. The guest lane's HEVC check compared each frame the guest decoded with ffmpeg 9.0.2's software decode, and two streams coded with 16x16 CTBs (1366x766 and a 1280x720 bisect of it) differed on most frames. A bisect of x265's options pinned it to CTU 16 with SAO and deblocking both on, and the difference was first taken for a bug of NVIDIA's decoder, with a host self-check planned to refuse such streams. It was ffmpeg: x265's reconstruction (`--recon`) of the same streams equals NVIDIA's decode (through the core, ffmpeg's Vulkan hwaccel and NVDEC), VideoToolbox's on an M3 Max and the guest's on every frame, and ffmpeg's software decode differs from all four (**measured**, 2026-11-03; upstream report 98). `hevc-check.sh` had already found the same difference on AMD's decoders and checks against the reconstruction where the two differ; a check written later against ffmpeg alone met it again. How to spot the next one: when hardware decoders disagree with a software reference, compare each with the encoder's own reconstruction, and with a second vendor's hardware, before calling the hardware wrong; a check that has one software reference has none for the streams that reference gets wrong.
- A test built from a model of a guest's struct checks the writer, never the model. The guest driver's HEVC writer read AppleGVA's short-term sets with the delta lists at `+0xe8` and the flags after them; at `+0xe8` a predicted set held bytes of 1, which was read as "AppleGVA keeps the prediction's syntax but not the pictures", and the writer gained a derivation of its own (7-61, 7-62). The unit tests built AppleGVA's form of the stream from the same layout, so they passed, and the guest refused the stream's SPS on every picture. A dump of AppleGVA's real struct, compared with the stream's own syntax at every field, showed the flags at `+0xe8` and `+0xf8` and the deltas at `+0x108` and `+0x148`, every set's pictures derived by AppleGVA itself (**measured**, 2026-11-03, `hevc-main-720p-sets-sps`, 25 sets). How to spot the next one: before reading meaning into a field of a guest-held record, dump the record for an input whose every value is known and match each field to it; where only one stream exercises a field, the tests that model it say nothing about the guest.
- Tests that make throwaway git repositories inherit git's environment. `git rebase -x` and git's hooks export `GIT_DIR` and its kin to what they run, and `git -C DIR` does not override them. reims-ctl's tests of its update and its installer, run under `git rebase -x` in a linked worktree, ran their `git init`, `config` and `commit` on the enclosing repository: its shared config became `core.bare=true` with the tests' `user.name` and `user.email`, which stopped the main checkout ("this operation must be run in a work tree") and gave another worktree's commit the tests' author (**measured**, 2026-11-07). reims-ctl now drops those variables for each git and script it runs on a checkout, its tests' included (`update::GIT_REPOSITORY_ENV`). Never run tests under `git rebase -x` in a worktree that shares the main checkout's `.git`: check each commit in a worktree of its own (`git worktree add --detach`). How to spot the next one: a config change or a commit in a repository no command named, made while a hook or a rebase's exec ran.
- A driver's answers can disagree, and a rule derived from one of them takes its value on every driver. The H.264 caps' cut to 65,535 macroblocks (bugs.md, U28) kept the driver's largest width and lowered the height, tested on radeonsi's answer of 4096x4096. iHD answers 8192x8192 in `VAConfigAttribMaxPictureWidth` and `Height` while its surfaces' bound, and the widest picture it decodes, is 4096x4096, so the cut answered 8192x2032 there and the guest refused 3840x2160 at its create. Spot it by feeding each rule every driver's real answers, and the sizes users play (3840x2160, 4096x2160), not only the case the rule was written for.