Fix Android memfd buffer registration rollback#81
Closed
cursor[bot] wants to merge 1 commit into
Closed
Conversation
Co-authored-by: dallison <dallison@users.noreply.github.com>
Owner
|
Superseded by #82, which contains the same fix re-authored under a CLA-covered account (plus a build/test fix for the Android shmem path on platforms without memfd_create). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
On Android non-split memfd channels,
PublisherImpl::CreateOrAttachBuffersadvancedccb_->num_buffersbefore registering the new buffer FD with the server. IfRegisterClientBufferfailed after that CAS, subscribers could observe a new buffer generation that the server could not provide, causing reload failures and eventual abort when a slot referenced the missing buffer.Root cause
The Android FD broker requires server registration before other clients can map a buffer, but the error path returned without rolling back the shared
num_bufferscount or clearing the publisher's local unregistered buffer state.Fix
Roll back
ccb_->num_bufferson registration failure when it still points at the failed generation, clear the corresponding BCB sizes, and unmap/drop local buffers beyond the last fully registered generation. Also makeSUBSPACE_SHMEM_MODEoverridable so the Android memfd path can be tested on Linux, and update memfd includes accordingly.Validation
bazelisk test //client:client_test --test_filter=AndroidBufferRegistrationTest.FailedRegistrationRollsBackNumBuffers --cxxopt=-DSUBSPACE_SHMEM_MODE=SUBSPACE_SHMEM_MODE_ANDROIDbazelisk test //client:client_test --test_filter=ClientTest.Resize1:ClientTest.ResizeCallbackbazelisk test //client:client_testbazelisk test //client:client_test --cxxopt=-DSUBSPACE_SHMEM_MODE=SUBSPACE_SHMEM_MODE_ANDROID