Skip to content

fix(MachPort): silence concurrency check for mach_task_self_ - #379

Draft
aryansk wants to merge 1 commit into
apple:mainfrom
aryansk:codex/swift-system-373-mach-concurrency
Draft

fix(MachPort): silence concurrency check for mach_task_self_#379
aryansk wants to merge 1 commit into
apple:mainfrom
aryansk:codex/swift-system-373-mach-concurrency

Conversation

@aryansk

@aryansk aryansk commented Aug 11, 2026

Copy link
Copy Markdown

Summary

Import Darwin.Mach with @preconcurrency so mach_task_self_ (a shared global from Mach) does not trigger Swift 6.3's concurrency check:

error: reference to var 'mach_task_self_' is not concurrency-safe because it involves shared mutable state

The existing call sites (mach_port_guard, mach_port_destruct, etc.) keep their current form; the import attribute suppresses the diagnostic for this known thread-safe global without per-call-site workarounds.

Issue

Fixes #373 — 1.8.0 mach_task_self_ concurrency error on macos-14 GHA with Swift 6.3.

Validation

  • git diff --check passes

Darwin.Mach's mach_task_self_ is a shared global; Swift 6.3
reports it as not concurrency-safe when imported. Use a
preconcurrency import so the existing call sites remain valid
without per-call-site suppression.

Fixes apple#373
@glessard

Copy link
Copy Markdown
Contributor

The concurrency annotations for mach_task_self_ were introduced in the macOS 15.4 SDK. Is there a way to satisfy the older deployment target without weakening the import for the modern SDKs?

@aryansk

aryansk commented Aug 12, 2026

Copy link
Copy Markdown
Author

Thanks for the clarification. I checked the issue and the current change. Since the annotations come from the macOS 15.4 SDK, the preconcurrency import would suppress them for modern SDKs too. I do not see a portable SDK-version conditional at this import site, so I am leaving the code unchanged rather than broadening suppression. If Swift System has a supported wrapper or conditional pattern for this SDK boundary, I can apply that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.8.0 mach_task_self_ concurrency build error on macos-14 GHA runners

2 participants