binder: add unit tests for Inbound. Use them to repro & fix an edge case in delivery - #13032
Open
jdcormie wants to merge 3 commits into
Open
binder: add unit tests for Inbound. Use them to repro & fix an edge case in delivery#13032jdcormie wants to merge 3 commits into
jdcormie wants to merge 3 commits into
Conversation
…getDelegate() Permits fake/mock implementations in tests that aren't actually backed by an IBinder at all. TAG=agy CONV=a7051e19-0fc1-42a4-8b24-5c2e3373aa0c
jdcormie
force-pushed
the
ooo-msg-before-prefix
branch
from
September 6, 2026 07:31
ab3fd56 to
6dead46
Compare
jdcormie
force-pushed
the
ooo-msg-before-prefix
branch
from
September 8, 2026 23:38
6dead46 to
5250095
Compare
It's hard to unit test Inbound in isolation because of its many hard-coded concrete dependencies. However, without unit tests, we can't safely refactor Inbound to fix this either! Introduce ClientInboundTest and ServerInboundTest, which bootstrap a way out of this mess by creating an Inbound indirectly via a dummy BinderTransport. TAG=agy CONV=a7051e19-0fc1-42a4-8b24-5c2e3373aa0c
Inbound's queuedTransactionData holds message fragments from the peer that haven't yet been assembled and delivered to the application. Binder transactions are sent in index order and must contain at least one of: a prefix, part/all of a message, and a suffix. When a transaction with message data arrives before its predecessors (according to index), Inbound's enqueueTransactionData() reserves slots for those predecessors in queuedTransactionData. After each predecessor transaction trickles in, enqueueTransactionData() checks whether it completes the message, which can then be delivered. There's an edge case, though, where a late-arrival transaction contains just the prefix with no message data at all. In that case, Inbound remove()s the queuedTransactionData slot it previously reserved and carries on without considering that this prefix-only transaction might have completed the first message! And if that was the final transaction in the stream, Inbound will never call lookForCompleteMessage() again, leaving the stream stuck forever with a complete but undelivered message.
jdcormie
force-pushed
the
ooo-msg-before-prefix
branch
from
September 9, 2026 00:26
5250095 to
6ecb42d
Compare
dbgalur
approved these changes
Sep 11, 2026
dbgalur
approved these changes
Sep 11, 2026
dbgalur
approved these changes
Sep 11, 2026
Member
Author
|
@kannanjgithub, could you consider this for approval? My colleague has reviewed it for Android. |
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.
Regression testing this bug fix required building unit tests for Inbound (it currently has none). We'll rely on these tests for other, bigger, upcoming changes like #12747 and #9010.
Will not squash please review each commit individually.