Status Update
Comments
jc...@magicleap.com <jc...@magicleap.com> #2
en...@google.com <en...@google.com> #4
for all who are looking for a solution use this:
jc...@magicleap.com <jc...@magicleap.com> #5
Indeed, I see similar logic in usb_write() in usb_linux. maxPacketSize is 512 (a power of 2) on my Ubuntu environment, so all good there as far as runtime behavior. It sure is odd that on macOS it's 5120, which happens to be exactly 10x the linux value. Seem suspicious, doesn't it?
Yeah, on the CHECK thing... I guess I see the client and server as a closed system in that the code is developed and distributed together. That said, obviously anyone can write their own adb client/server, so in that respect, I agree with the disagreement :-)
jc...@magicleap.com <jc...@magicleap.com> #6
5120 is likely not really the maxPacketSize on our Macs. It's probably 512. And a burst is probably 10 packets.
Note that usb_osx.cpp calculates the maxPacketSize as follows
if (maxBurst != 0)
// bMaxBurst is the number of additional packets in the burst.
maxPacketSize /= (maxBurst + 1);
If the theory about packet size truly being 512 is correct, then it means the real bug is in GetPipePropertiesV2() returning zero for maxBurst instead of 9. If it returned 9, then maxPacketSize would be 512 (again, a power of 2), and the zero_mask expression would work out just fine. All situations where we've had our adbd abort because of the unexpected stowaway amessage header in a packet are ones where the sent buffer are an integer multiple of 512. None are an integer multiple of 5120.
Still there's no denying that the unchecked assumption of maxPacketSize being a power of 2 is a bug. Changing the code to use modulus operation instead of a bit-mask check would be technically more correct, but wouldn't fix the broken behavior in our case, since ultimately, it appears the maxPacketSize adb is getting is wrong. But if you had an assert in the client/server on macPacketSize being a power of 2, then that would at least have brought the incorrect maxPacketSize issue front and center.
jc...@magicleap.com <jc...@magicleap.com> #7
df...@magicleap.com <df...@magicleap.com> #8
From GetEndpointPropertiesV3's documentation:
... The wMaxPacketSize is the BASE maxPacketSize as found in the endpoint descriptor, and has not been multiplied to take into account burst and mult...
Whereas GetPipePropertiesV3 documentation states that it does mention is may be a multiple
> .. current FULL maxPacketSize for this pipe, which includes both the mult and the burst...
So using GetEndpointProperties would avoid the need to compute the actual max packet length which goes wrong.
en...@google.com <en...@google.com> #9
use GetPipePropertiesV2 ( and not GetEndpointProperties)
the opposite way round, right? we should switch to GetEndpointProperties?
do you have a pointer to the docs? my search-fu failed me :-(
sh...@google.com <sh...@google.com>
[Deleted User] <[Deleted User]> #11
جهازي مخترق
sh...@google.com <sh...@google.com> #12
sh...@google.com <sh...@google.com> #15
en...@google.com <en...@google.com> #16
(i've added dvander to the fastboot cl, since he's the fastboot owner.)
magicleap folks: please take a look if you have time, and note that you can download prebuilt binaries from ci.android.com if you want to test but can't easily rebuild yourselves. these changes will go out in the next platform tools release, so let us know if they don't solve the issues you've been seeing!
ph...@gmail.com <ph...@gmail.com> #17
sh...@google.com <sh...@google.com> #18
Release Notes:
34.0.0 (February 2023)
adb
Fixed zero length packet sends for macOS [(issuetracker: 208675141)](
Addressed unstable connectivity (MacBook high speed cable): frequent adb disconnects.
Improved error message for adb push with insufficient number of arguments.
fastboot
Improved flashing: `flashall` will now skip reboots to userspace if it can.
Fixed zero length packet sends for macOS [(issuetracker: 208675141)](
Fixed flashing recovery.img resulting in wrong AVB footer.
ju...@gmail.com <ju...@gmail.com> #19
ju...@gmail.com <ju...@gmail.com> #20
sh...@gmail.com <sh...@gmail.com> #21
ka...@gmail.com <ka...@gmail.com> #22
I am not a robot
ju...@gmail.com <ju...@gmail.com> #23
ju...@gmail.com <ju...@gmail.com> #24
ju...@gmail.com <ju...@gmail.com> #25
[Deleted User] <[Deleted User]> #26
Hy
tr...@gmail.com <tr...@gmail.com> #27
xu...@gmail.com <xu...@gmail.com> #28
Google.com
xu...@gmail.com <xu...@gmail.com> #29
google.com
fa...@hotmail.com <fa...@hotmail.com> #30
Good
ju...@gmail.com <ju...@gmail.com> #31
fr...@gmail.com <fr...@gmail.com> #32
ka...@gmail.com <ka...@gmail.com> #33
on
My address country India jila Sultanpur post kamtaganj gram basti paharpur Narsinghpur My name is Arun bihari
fa...@gmail.com <fa...@gmail.com> #34
br...@gmail.com <br...@gmail.com> #35
Enviado desde mi Samsung Mobile de Telcel
-------- Mensaje original --------De: buganizer-system@google.com Fecha: 1/8/23 9:50 p. m. (GMT-06:00) Para: b-system+-1105710592@google.com Cc: brotherskankandpechei@gmail.com Asunto: Re:
Replying to this email means your email address will be shared with the team that works on this product.
Changed
fa...@gmail.com added
Goot
_______________________________
Reference Info: 208675141 Bug in usb_osx.cpp logic for sending Zero Length Packet
component: Android Public Tracker > App Development > SDK > platform tools > adb
status: In Progress (Accepted)
reporter: jc...@magicleap.com
assignee: sh...@google.com
cc: ad...@google.com, en...@google.com, jc...@magicleap.com, and 1 more
type: Bug
access level: Default access
priority: P2
severity: S2
retention: Component default
Generated by Google IssueTracker notification system
You're receiving this email because you are subscribed to updates on Google IssueTracker
Unsubscribe from this issue.
sh...@google.com <sh...@google.com>
on...@gmail.com <on...@gmail.com> #36
ro...@gmail.com <ro...@gmail.com> #37
ro...@gmail.com <ro...@gmail.com> #38
pr...@gmail.com <pr...@gmail.com> #39
da...@gmail.com <da...@gmail.com> #40
af...@gmail.com <af...@gmail.com> #41
7a...@gmail.com <7a...@gmail.com> #42
20240720111212800100166608922333431
sa...@google.com <sa...@google.com>
sa...@google.com <sa...@google.com> #44
Fixed in aosp and will be fixed in adb 36.0.0
Description
maxPacketSize=5120
zero_mask = 5120-1 = 0b1001111111111
usb_write() is called with buffer of length 1024 0x10000000000
The following expression in usb_write() will not properly determine when to send the ZLP.
if(!(len & handle->zero_mask)) {
In some cases, a ZLP will be written when it's not needed (the ZLP is only needed when the amount of data being written is an integer multiple of maxPacketSize, as explained here
In a much more troubling case, a ZLP will NOT be written when it should. Imagine, in the above scenario (maxPacketSize=5120), that usb_write() is called with 5120. The expression !(5120 & 5119) resolves to false, and so a ZLP is not sent, but clearly 5120 is an integer multiple of 5120, and thus a ZLP should be sent. This can absolutely result in buggy behavior. In fact, with Android 10 devices, it can result in adb aborting. How? Well, because a ZLP hasn't been sent, the buffer may be combined with a subsequent write and adbd might receive a combination of two amessages (the final payload portion of one message, and a header (24 bytes) of the next amessage). We are in fact seeing that happen. And because UsbFfsConnection::ProcessRead() in Android 10 has a CHECK_LE() to ensure the final read of an amessage has exactly the expected remaining bytes of the amesssage and not one byte more, then adbd aborts (effectively "crashes").