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

Crash in verifier method when using preconditionIsolated with iOS 17, xcode 15 #8371

Closed
sssuourabh opened this issue Sep 21, 2023 · 2 comments

Comments

@sssuourabh
Copy link

sssuourabh commented Sep 21, 2023

How frequently does the bug occur?

Always

Description

`actor RealmActor {
var realm: Realm!
init() async throws {
realm = try await Realm(actor: self)
}

func fetchModelObjects<T: Object>(_ type: T.Type) async throws -> [T] {
    guard let realm = realm else {
        debugPrint("Realm is not initialized:")
        return []
    }
    let objects = realm.objects(T.self)
    return objects.map { $0}
}

}`

Stacktrace & log output

RealmSwift/Realm.swift:1469: Precondition failed: Incorrect actor executor assumption; Expected 'UnownedSerialExecutor(executor: (Opaque Value))' executor.

Can you reproduce the bug?

Always

Reproduction Steps

when i call to fetch objects it returns me objects but as soon as i start using that it crashes at

#if swift(>=5.9) // When possible use the official API for actor checking if #available(macOS 14.0, iOS 17.0, tvOS 17.0, watchOS 10.0, *) { return { self.preconditionIsolated() } } #endif

Usage is defined like below:

let realmDB = try! await RealmDBActor() let projectList = try! await realmDB.fetchModelObjects(ProjectObject.self) debugPrint(projectList)

image attached of fetched objects :

Version

10.42.3

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 17

Build environment

Xcode version: XCODE 15
Dependency manager and version: - SPM

@sssuourabh
Copy link
Author

@tgoyne
Copy link
Member

tgoyne commented Sep 21, 2023

You are returning actor-isolated objects out of the actor, which is not a legal thing to do. Enabling sendability checking for your project will give compile-time warnings that calling fetchModelObjects() is unsafe.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants