Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 16: Write Blocks Risk Data Races Warnings #8628

Open
bdkjones opened this issue Jun 18, 2024 · 6 comments
Open

Xcode 16: Write Blocks Risk Data Races Warnings #8628

bdkjones opened this issue Jun 18, 2024 · 6 comments

Comments

@bdkjones
Copy link

bdkjones commented Jun 18, 2024

How frequently does the bug occur?

Always

Description

I'm sure you guys are all over this, but opening a Realm project with Xcode 16 generates roughly 87 bajillion new warnings for simple code like this:

// Assume we're on an Actor and have an actor-isolated realm opened named `actorRealm`:
let newFoo: Foo = Foo()

try actorRealm.write {
   actorRealm.add(newFoo)    // Warning: Sending 'newFoo' risks causing data races; this is an error in the Swift 6 language mode
}

I see some changes in #8618 that look like they might address this, but I'm throwing this here anyway just in case.

Stacktrace & log output

This warning appears essentially everywhere that *anything* is used in a write block.

Can you reproduce the bug?

Always

Reproduction Steps

Open a Realm 10.51.0-based project in Xcode 16.

Version

10.51.0

What Atlas Services are you using?

Atlas Device Sync

Are you using encryption?

No

Platform OS and version(s)

macOS 14.5

Build environment

Xcode version: 16.0 beta (16A5171c)
Dependency manager and version: SPM

Copy link

sync-by-unito bot commented Jun 18, 2024

➤ PM Bot commented:

Jira ticket: RCOCOA-2391

@tgoyne
Copy link
Member

tgoyne commented Jun 18, 2024

Everything except for the warning from async Realm.init(actor:) should be fixed by #8618. That warning remains because an isolated init currently just crashes the compiler; if that goes unfixed by the time Xcode 16 makes it out of beta we'll probably need to add a Realm.open() static function or something.

@bdkjones
Copy link
Author

Just a heads up: I updated to 10.52.0 and these warnings are not resolved.

@bdkjones
Copy link
Author

Here's what I'm seeing in Xcode 16 beta 1 with 10.52.0:

Screenshot 2024-06-18 at 21 14 31

@bdkjones
Copy link
Author

A thought: I haven't actually switched to Swift 6 language mode in this project because there are a few other blockers unrelated to Realm.

I see some switches on the compiler version in the latest Realm update, so perhaps these are false warnings that evaporate with no errors once Swift 6 is enabled? I'll try that when I get back to my Mac this evening.

If that's the case, the ubiquitous warnings when the Swift version is <6 are going to mislead a lot of people and are worth resolving.

@bdkjones
Copy link
Author

Ha, I tried building in Swift 6 Language Mode but Xcode just spat out 13 "Swift compiler failed with a non-zero exit code" errors that have absolutely zero context—there's no associated lines or files, so I have no idea what the "errors" are.

This seems like a really bad inflection point in Swift. People are just going to use the 6.0 compiler in 5.0 language mode for the next seven years. Anyway, good luck!

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

No branches or pull requests

2 participants