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 reattaching the allocator after compact #3828

Merged
merged 1 commit into from
Jul 21, 2020
Merged

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Jul 20, 2020

SlabAlloc::detach() sets m_youngest_live_version to 0 and attach() doesn't touch it (as it comes from the lockfile rather than anything it has access to), so compact needs to set m_youngest_live_version after attaching the allocator to the new Realm file. Failing to do this resulted in the first ref translation table being deallocated after the first write transaction even if it was still in use, resulting in a use-after-free for whatever was using it.

Fixes realm/realm-swift#6652. Fixes realm/realm-swift#6628. Fixes realm/realm-swift#6555.

SlabAlloc::detach() sets m_youngest_live_version to 0 and attach() doesn't
touch it (as it comes from the lockfile rather than anything it has access to),
so compact needs to set m_youngest_live_version after attaching the allocator
to the new Realm file. Failing to do this resulted in the first ref translation
table being deallocated after the first write transaction even if it was still
in use, resulting in a use-after-free for whatever was using it.
@tgoyne tgoyne self-assigned this Jul 20, 2020
@tgoyne tgoyne requested review from jedelbo and finnschiermer July 20, 2020 21:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants