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

Fix spurious incorrect thread exceptions due to threadid reuse #6714

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Aug 20, 2020

We key the Realm cache on the thread ID, but thread IDs are not actually unique over the lifetime of the process. This means that the cached Realm may have been created on a different thread with the same ID, which means that it'll be bound to a different runloop than the current thread's runloop. Check for this, and simply open a new Realm instead of reusing the cached Realm when this happens.

Fixes #6659. Fixes #6689. Fixes #6712.

We key the Realm cache on the thread ID, but thread IDs are not actually unique
over the lifetime of the process. This means that the cached Realm may have
been created on a different thread with the same ID, which means that it'll be
bound to a different runloop than the current thread's runloop. Check for this,
and simply open a new Realm instead of reusing the cached Realm when this
happens.
@tgoyne tgoyne requested a review from leemaguire August 20, 2020 16:30
@tgoyne tgoyne self-assigned this Aug 20, 2020
@tgoyne tgoyne merged commit 4462f4c into master Aug 20, 2020
@tgoyne tgoyne deleted the tg/threadid-reuse branch August 20, 2020 19:34
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants