Repository navigation
ci: stop rcodesign finalizing and unloading the PKCS#11 module - #32333
Merged
Merged
Conversation
rcodesign intermittently died with SIGSEGV in the build workflow on main, after it had written the signed darwin binary. make then deleted the output and the job failed. The patch we apply made rcodesign call C_Finalize once signing was done and drop the module context, which unloads the library. When the Cloud KMS library authenticates with Google credentials, most of its threads are still running at that point, so one of them can run after the library is unmapped. The module context now stays in the process-wide registry until the process exits, so the library is neither finalized nor unloaded.
kylecarbs
approved these changes
Nov 17, 2026
This branch had an error being deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
rcodesignhas died with SIGSEGV in three of the 33 runs of thebuildworkflow onmainso far (43966274499, 44090943038, 44142588433). Each time it had already written the signed darwin binary.makethen deleted the output and the job failed.The patch we apply to
rcodesignmade it callC_Finalizeonce signing was done and drop the module context, which unloads the library. When the Cloud KMS library authenticates with Google credentials,C_Finalizereturns with most of the library's threads still running, and a thread that runs after the library is unmapped faults.The module context now stays in the process-wide registry until the process exits, so the library is neither finalized nor unloaded. That is the one way the patch now differs from indygreg/apple-platform-rs#350, and its header says so. The patch's unit test is cut down to the behavior that is left.
No pull request job runs this action: only the signing builds in
build.yamlandrelease.yamlcall it, so the first real run isbuildonmainafter the merge. The crash reproduces locally withlibkmsp111.9 against a fake Cloud KMS over TLS and anexternal_accountcredential of the kindgoogle-github-actions/authwrites. Both binaries were built with the action's own commands and toolchain:rcodesignbuilt withmainmainIn all 12 instrumented crashes the fault was on a thread other than the main one, at an address inside the range the unload had just unmapped, after
writing Mach-Owas logged. With this patch the library is never unmapped. The new binary also signs throughscripts/sign_darwin.shwith the Cloud KMS library and directly with a SoftHSM token, and the signatures verify against the signing certificate.This does not address the other failure seen in the same workflow (44137012528), where
rcodesigncould not reach Apple's timestamp server.Note
An AI agent (Xum) wrote this change for @sreya and ran the local tests above.