Metal's compiler service crashes on some world pipelines (macOS 15 and 27); the first run still pays each crash #181
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T23:14:58Z.
Reported by @alicans in #15 (M4 Pro 24 GB, macOS 15.8.2, commits
561e783and0133b82).At the first world frame, a few graphics pipelines fail with
title shader refused … reason=conversion: Compiler encountered an internal error. Each one takes about 30 s, and they fail one after another. Each failure matches anMTLCompilerServicecrash report:EXC_BAD_ACCESSat 0x0, inlibLLVM.dylibunderllvm::RegAllocBase::allocatePhysRegs(). It's the same with D3DMetal's converter and with Apple's Metal Shader Converter 4.0.3, so the bug is in the OS's Metal backend compiler. The macOS 27 testers don't see it.Four of these in a row hold the first world frame past the title's 30 s watchdog.
Pipelines seen failing (vertex / pixel):
6eedbc0771df10ab/615820c53854c962,76d4606196dfd196/5a1c651829a060de,08ebaafa2f409986/59c5abdcb23974a7,26e9f04a4c9c8146/725962e1f1be4855,9cb2687cedff2979/5d85e2176433f3af,a1785729710c22b3/80b896aafd2ec5f4.Plan:
VICTORY_SKIP_PIPELINESon Windows).macOS 15 testers: the crash reports in
~/Library/Logs/DiagnosticReports/(MTLCompilerService*) and the refused hashes from your log help.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alicans on 2026-11-26T23:20:15Z.
Here are four more pipelines whose pixel shader crashes
MTLCompilerServiceon macOS 15, beyond the six listed above (sameallocatePhysRegsstack):3f04c18f62a176a0,215b7ef6f2a22dd7,f5fa188ea38ad066,d4ad36beb4d0ead9(the last is also in the macOS 27 reports in #15).When I skipped the first six with a local build switch, the frame moved on until these four crashed, so a skip list keeps growing. A fix that stops a failed compile from holding the frame looks like the right fix.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by cocobailey on 2026-11-27T00:16:43Z.
Data point: this also happens on macOS 27.2.1 (M2 Pro, 19-core GPU, 32 GB, Series X,
mainatb16bd61, Apple Metal Shader Converter 4.0.3). The first-world-frame stall from this issue is what ended my run.00:05:09to00:05:35in the log). All 26 failed with:conversion: Compilation failed due to an interrupted connection: XPC_ERROR_CONNECTION_INTERRUPTED. This error occurred after multiple retries.Then came the title's watchdog: the first-chance fault at
image+0x23cf683and the follow-on atimage+0x55e56f8, 240 s into the run.~/Library/Logs/DiagnosticReports/holds 25MTLCompilerService-*.ipsreports from that minute. The one I opened isEXC_BAD_ACCESS/KERN_INVALID_ADDRESS at 0x0inRegAllocBase::allocatePhysRegs(). On this Mac each failure takes about 1 s, not about 30 s, but 26 of them plus the first binds still hold the frame past 30 s.615820c53854c962,80b896aafd2ec5f4,5a1c651829a060de,725962e1f1be4855,3f04c18f62a176a0,215b7ef6f2a22dd7andd4ad36beb4d0ead9are all in my set. The full set, vertex/pixel:11a9c30cfe1f8d12/dac2fa6fb7f3e7f420087581f0415fa3/c0141d556080a58324c08e1708a0a35a/215b7ef6f2a22dd726e9f04a4c9c8146/3f04c18f62a176a026e9f04a4c9c8146/725962e1f1be485526e9f04a4c9c8146/f93f9dd97ec58cdb40fcb7bed95171e7/a883ec641fc32851461e914e41ceff00/de25dd4df5ce88925ab3b2f9f61f41ba/7eb47ca32a9d272a63383a23c604b343/332f4d557a5040bc6eedbc0771df10ab/615820c53854c9626eedbc0771df10ab/6edf5167026e3dbe75cbf35d42189e84/a8606222a786b0f476d4606196dfd196/5a1c651829a060de90fb900a17eef1c3/57b7d350d98fb065987c0ba37de4efa3/f7e5ddc993c9948a994ca610d79bc72a/874ee2389903bc24a083f468ac884062/0be26eda600f00fea1785729710c22b3/80b896aafd2ec5f4a2aff0c4c911c4d2/75cb9d761d620c68bd0d61e5418dbf0e/19d4b5ed6d255361bd0d61e5418dbf0e/5925af9ef95a3699c0cf126f21be23b4/3783b66b70b44479e68ea4e1af3889fb/396c5139187e803be68ea4e1af3889fb/51420b6138ab50d8f88583f4d9c5f9bb/d4ad36beb4d0ead9Reproduced on a second run (setup already done, so straight to the story load): 28 pipelines refused with the same XPC error from about 154 s, 26 of them the same pixel shaders as the first run, then the same watchdog pair at about 183 s.
So "macOS 27 testers don't see it" doesn't hold for every Mac. It may depend on the GPU family (Apple8 here) as well as the OS version. That supports the plan's first point: a failed compile shouldn't hold the frame. I'm happy to test a branch that compiles these off the frame or gives up early.
AI-assisted testing and write-up, prepared with Claude Code. No game data attached.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T00:20:11Z.
Partial fix on main
fd861760: a render pipeline whose compile crashes Metal's compiler service (XPC_ERROR_CONNECTION_INTERRUPTED) is now recorded in the cache, keyed by the pipeline and the macOS build, and later runs refuse it at once instead of crashing the service again. The first run still pays each crash once; making that fail fast is next. macOS 15 testers: a cold run then a warm run on current main would show whether the second run gets past the first world frame.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Ketan-Kapse on 2026-11-27T06:00:26Z.
A cause and a fix for this from a fork (M4 Pro, 24 GB, macOS 27, Series S, Metal Shader Converter 4.0 beta 3). On our side it was not the OS compiler choking on valid input: the converted library was already invalid IR, and the translator's export loop is what made the converter produce it.
How we saw it
XPC_ERROR_CONNECTION_INTERRUPTEDevery time (sameRegAllocBase::allocatePhysRegsstack as here). The same mesh library with a trivial fragment function, or with no colour attachments, built fine, and a passing mesh with the failing pair's pixel shader built fine. So the mesh program is at fault once its outputs are live.metal-objdump -d <lib>.metallibgives the IR, andmetal-asrefuses it:Instruction does not dominate all uses!, for exampleand the same with
air.convert.f.f32.f.f16results. All 66 failing libraries we dumped had such errors (33 of 110 passing ones too, where the code is dead or tolerated).Cause
The converter gathers the component stores of one output into a vector at the first store of that output. The export loop in
emit/lower.rs(thestoreOutput/storeVertexOutput/storePrimitiveOutputloop) makes each component's value (the float cast,legacyF16ToF32) between the stores, so later components are defined after the gathered vector uses them.Fix
Make every component's value first, then emit the stores back to back:
Result here
metal-as(0 dominance errors).What I have not checked
Our failing pipelines were mesh + pixel pairs on the stream-pipeline path (we answer
E_NOTIMPLto the console pipeline methods, so the title falls back to described stages). The pipelines listed in this issue are vertex / pixel pairs on macOS 15. The same loop emitsstoreOutputfor vertex shaders, so I expect the same fault, but I have not run those hashes.metal-ason one of the failing libraries would confirm it in a few seconds.Happy to send this as a PR if that is easier.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T06:05:30Z.
@Ketan-Kapse thank you, this reads right: a build that fails only when the mesh program's outputs are live, and IR that
metal-asrejects with a dominance error, is a far better explanation than the OS compiler choking on valid input. Yes please, send it as a PR.What I will check on our side, on the console-pipeline path:
metal-objdumpandmetal-ason the converted libraries of the vertex / pixel pairs listed in this issue, before and after your change. Our runs still log conversions that end inXPC interrupted(12 lines in the last 600 s world run), so there is something to measure.For the PR:
storeOutput,storeVertexOutputandstorePrimitiveOutput. If a small synthetic program can be converted and passed throughmetal-asin a test that skips when the tools are absent, better still.One question: the 33 passing libraries that also had dominance errors, did they stop having them after the change too? If any error remains after it, there is a second site that makes values between stores.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Ketan-Kapse on 2026-11-27T06:08:21Z.
PR coming, with a test that pins the order for all three store kinds.
On your question: yes. Every library dumped after the change passed
metal-aswith 0 dominance errors, 143 of 143, and that set includes the shaders that were among the 33 "passing but invalid" before. I matched 122 old/new pairs by their DXIL sizes and compared the IR: the output calls and declared output types are identical, and what differs is 0 to 33 lines per shader where the same values are carried as float instead of i32. So I see no second site, at least in the mesh and pixel pairs this scene uses. I will put the before and after counts in the PR and say that fingerprints change while outcomes do not.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T06:48:29Z.
Thank you, that answers my question: no dominance error left in 143 of 143 libraries means there is no second site that makes values between stores, at least for the mesh and pixel pairs you dumped.
For the pull request, please put in the body the counts you gave here (66 failing and 33 of 110 passing before, 0 of 143 after) and the number of shaders whose outcome changes, which should be none. I will run the vertex and pixel pairs listed in this issue on the console-pipeline path and post the compiler failure count per run, cold, before and after.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ShadyUnderLight on 2026-11-27T10:40:55Z.
/claim
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T10:41:06Z.
Claimed by @ShadyUnderLight. Open a draft pull request with
Refs #181in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ShadyUnderLight on 2026-11-27T10:41:11Z.
Claiming the second half of the plan in the issue, not the root cause: a compile that fails or crashes must not hold the frame (give up early), on the console-pipeline path.
I read #263 as the fix for the cause (invalid IR from the export order), with tests, and I will not touch it. What I am taking is the safety net for the cases #263 does not explain — the vertex/pixel pairs listed here on macOS 15 were never confirmed to have the same cause — plus the 1 s × 26s stall itself.
Scope: when the converter reports a compiler crash, or a compile has not finished by the time the draw needs it, the draw is dropped and counted for this run instead of waiting; the pipeline is remembered so later frames do not retry it in the frame. Nothing changes for compiles that succeed.
I will post the design and the numbers before opening a draft pull request.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-27T13:19:05Z.
Tester data for #263: its merge commit against the commit just before it.
M4 Max, 128 GB, macOS 27.2.1, Apple's Metal Shader Converter 4.0 beta 3, Series X, windowed. New game from an empty data folder, keys scripted through the setup screens, 200 s per run. Each build got a new, empty shader cache folder, and its three runs share it. One local change on both builds: the sound output is replaced by the silent one.
b54fab42(parent), runs 1 / 2 / 3e2f211a8(#263 merged), runs 1 / 2 / 3XPC_ERROR_CONNECTION_INTERRUPTEDrefusalstitle shader refusedlinesSo on this Mac the parent crashes Metal's compiler in the first two runs and then refuses about 86 pipelines from its crash list, and with #263 there is no compiler crash and no crash refusal in three runs. Three more runs on
86786a7showed the same zeros.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ShadyUnderLight on 2026-11-27T13:44:17Z.
One more line for that table, from a different machine and a different build: M5 Max, 128 GB, macOS 27.2.1, Apple's Metal Shader Converter, series-x, headless, 400 s, on the latest main as of tonight (
5a7fb278, which has #263 and the pipeline-budget fix merged as3a03e6ed): 454title shader refusedlines, 0XPC_ERROR_CONNECTION_INTERRUPTEDand 0 "crashed on it on an earlier run". The two zeros reproduce here.For the record on the budget fix: with #263 in it has no crash left to spend a frame on. It stays as the backstop for a crash from another cause, since the macOS 15
allocatePhysRegsreports in this issue were never confirmed to be the same fault as the ones #263 explains.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T18:59:33Z.
The claim by @ShadyUnderLight has expired: no pull request referenced it within 24 hours. This issue is free to claim.