Skip to content

Fix sync delegate test crash in Xcode 27 beta.#511

Open
mbrandonw wants to merge 2 commits into
mainfrom
delegate-test-fixes
Open

Fix sync delegate test crash in Xcode 27 beta.#511
mbrandonw wants to merge 2 commits into
mainfrom
delegate-test-fixes

Conversation

@mbrandonw

Copy link
Copy Markdown
Member

Fixes #509.

Something different (I think!) in Xcode 27 causes traits to be evaluated on tests that are not actually run. That, coupled with SyncEngineDelegates being kept in memory for too long, caused a crash when running any tests that did not use the sync delegate trait. The fix is just to weakly hold onto the delegate in the SyncEngine.

That does mean that if anyone ever created a sync engine like this:

SyncEngine(
  ,
  delegate: MyDelegate()
)

…will have their delegate immediately deallocated, which would be a bug. Luckily all of our docs and sample apps show off holding on the delegate explicitly, which is standard practice in most Apple APIs.

@lukaskubanek

Copy link
Copy Markdown
Contributor

@mbrandonw Thanks for looking into it. I’ve tested it with Xcode 27 β4 and ef3cc19. Unfortunately, I’m still running into the crash when executing individual, unrelated tests. The MyDelegate instance gets intialized and deinitialized, which leads to the recording of the issue, which in turn crashes the test system.

@mbrandonw

mbrandonw commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Hi @lukaskubanek, thanks for checking. I was playing with two different fixes at once (the one in this PR, and then pointfreeco/swift-concurrency-extras#74) and maybe due to cached artifacts or pure luck it seemed like only the changes in this PR were necessary. But I think the changes in ConcurrencyExtras is the real fix. Wanna point to that branch locally to see if it fixes for you? (Edit: I just merged the PR so point to main instead).

If so, then I think we will close out this PR and just have people point to the newest ConcurrencyExtras if they need to run tests locally.

@lukaskubanek

Copy link
Copy Markdown
Contributor

@mbrandonw I pointed swift-concurrency-extras to main and I’m confirming that the patch in pointfreeco/swift-concurrency-extras#74 fixed the issue. So yes, this PR shouldn’t be needed and can be closed. The same goes for #509.

By the way, using @autoclosure for the trait parameter was what I had intuitively thought of as well. 🙂

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.

Issue recorded in MyDelegate.deinit crashes individual test runs in Xcode 27

3 participants