Skip to content

Remove Swift ObjC classes from Apple crypto native shim - #128917

Merged
vcsjones merged 3 commits into
dotnet:mainfrom
vcsjones:fix-128867-2
Jun 3, 2026
Merged

vcsjones merged 3 commits into
dotnet:mainfrom
vcsjones:fix-128867-2

Conversation

@vcsjones

@vcsjones vcsjones commented Jun 2, 2026

Copy link
Copy Markdown
Member

Replace Swift class-backed opaque handles with typed pointer-backed Swift value types so loading multiple copies of the Apple crypto native library does not register duplicate ObjC classes in the process.

Add a native build validation script that fails if future Swift bindings introduce locally-defined Swift ObjC class metadata so that we don't run in to this problem again, since it is basically impossible to catch in CI.

Fixes #128867

 Replace Swift class-backed opaque handles with typed pointer-backed Swift
 value types so loading multiple copies of the Apple crypto native library
 does not register duplicate ObjC classes in the process.

 Add a native build validation script that fails if future Swift bindings
 introduce locally-defined Swift ObjC class metadata.

 Co-authored-by: Copilot <[email protected]>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.

@vcsjones
vcsjones requested a review from bartonjs June 2, 2026 19:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Apple crypto native shim to avoid emitting Swift/ObjC class metadata (which is process-global) by replacing class-backed opaque handles with pointer-backed Swift value types. It also adds a post-build validation step to prevent reintroducing Swift ObjC class definitions in the future.

Changes:

  • Replace final class handle wrappers in pal_swiftbindings.swift with value types stored behind typed UnsafeMutablePointer<T> allocations, eliminating local Swift ObjC classes.
  • Add a new verify-no-swift-objc-classes.sh script that scans the built binary/archive for Swift ObjC class definitions.
  • Wire the new verification into the Apple crypto native library CMake post-build steps (shared + static).
Show a summary per file
File Description
src/native/libs/verify-no-swift-objc-classes.sh New validation script to detect Swift ObjC class definitions in the produced binary/archive.
src/native/libs/System.Security.Cryptography.Native.Apple/pal_swiftbindings.swift Replaces class-backed handles with pointer-backed value types to avoid Swift ObjC class registration.
src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt Adds post-build invocation of the new validation script for shared and static outputs.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Copilot AI review requested due to automatic review settings June 2, 2026 23:38
@vcsjones
vcsjones enabled auto-merge (squash) June 2, 2026 23:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new

@vcsjones
vcsjones merged commit 5e11a0f into dotnet:main Jun 3, 2026
117 checks passed
@vcsjones
vcsjones deleted the fix-128867-2 branch June 3, 2026 13:53
@vcsjones vcsjones added this to the 11.0.0 milestone Jun 3, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview6 Jun 17, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
@bartonjs bartonjs added the cryptographic-docs-impact Issues impacting cryptographic docs. Cleared and reused after documentation is updated each release. label Sep 11, 2026
@bartonjs bartonjs added the tracking This issue is tracking the completion of other related issues. label Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Security cryptographic-docs-impact Issues impacting cryptographic docs. Cleared and reused after documentation is updated each release. tracking This issue is tracking the completion of other related issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two CLR-based apps cannot coexist on Apple platforms

4 participants