Skip to content

ci: stop rcodesign finalizing and unloading the PKCS#11 module - #32333

Merged
sreya merged 1 commit into
mainfrom
rcodesign-skip-module-finalize
Nov 17, 2026
Merged

sreya merged 1 commit into
mainfrom
rcodesign-skip-module-finalize

Conversation

@sreya

@sreya sreya commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

rcodesign has died with SIGSEGV in three of the 33 runs of the build workflow on main so far (43966274499, 44090943038, 44142588433). Each time it had already written the signed darwin binary. make then deleted the output and the job failed.

The patch we apply to rcodesign made it 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, C_Finalize returns 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.yaml and release.yaml call it, so the first real run is build on main after the merge. The crash reproduces locally with libkmsp11 1.9 against a fake Cloud KMS over TLS and an external_account credential of the kind google-github-actions/auth writes. Both binaries were built with the action's own commands and toolchain:

rcodesign built with How it was run Runs Segfaults
the patch on main one at a time, idle machine 300 30
this patch one at a time, idle machine 300 0
the patch on main 32 in parallel, instrumented 3,000 12
this patch 32 in parallel, instrumented 3,000 0

In 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-O was logged. With this patch the library is never unmapped. The new binary also signs through scripts/sign_darwin.sh with 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 rcodesign could not reach Apple's timestamp server.

Note

An AI agent (Xum) wrote this change for @sreya and ran the local tests above.

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.
@sreya
sreya temporarily deployed to main November 17, 2026 20:32 — with GitHub Actions Inactive
@sreya
sreya temporarily deployed to main November 17, 2026 20:32 — with GitHub Actions Inactive
@sreya
sreya marked this pull request as ready for review November 17, 2026 20:46
@sreya
sreya requested a review from a team November 17, 2026 20:46
@sreya
sreya temporarily deployed to main November 17, 2026 20:46 — with GitHub Actions Inactive
@sreya
sreya merged commit 9c79ab7 into main Nov 17, 2026
58 checks passed
@sreya
sreya deleted the rcodesign-skip-module-finalize branch November 17, 2026 20:51
@sreya
sreya temporarily deployed to main November 17, 2026 20:51 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026

This branch had an error being deployed

1 failed and 1 inactive deployments
docs-preview — 7d621f65 Deployed Nov 17, 2026 by sreya via cleanup #178
main — 7d621f65 Deployed Nov 17, 2026 by sreya via cla #258950
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants