Skip to content

[codex] Fix global environment concurrency - #28

Merged
hainayanda merged 1 commit into
mainfrom
codex/fix-global-environment-concurrency
Jun 13, 2026
Merged

[codex] Fix global environment concurrency#28
hainayanda merged 1 commit into
mainfrom
codex/fix-global-environment-concurrency

Conversation

@hainayanda

Copy link
Copy Markdown
Owner

Problem

GlobalValues resolved instances while holding the registry lock. A resolver configured with resolveOn: could synchronously hop to another queue, access another global value, and deadlock waiting for the lock still held by the calling thread.

Moving assignment notifications outside synchronization also allowed delayed notifications to refresh observers with stale resolvers.

Solution

  • Snapshot registered resolvers under the recursive registry lock, then resolve them after unlocking.
  • Add per-key assignment revisions and filter notifications that are no longer current.
  • Keep Combine delivery outside the registry lock.
  • Restore independent synchronization for GlobalEnvironment state.
  • Simplify macro-generated getters to rely on the synchronized GlobalValues subscript.

Impact

resolveOn: resolvers can safely access other global values without cross-thread deadlocks, and observers ignore delayed stale assignment notifications. Public API behavior remains unchanged.

Validation

  • xcrun swift test (23 tests passed)
  • git diff --check

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@hainayanda
hainayanda marked this pull request as ready for review June 13, 2026 10:08
@hainayanda
hainayanda merged commit 1756467 into main Jun 13, 2026
3 checks passed
@hainayanda
hainayanda deleted the codex/fix-global-environment-concurrency branch June 13, 2026 10:09
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 participant