Debugging a crash in usbuhci!UhciAbortAsyncTransfer, I’ve come across the following:
usbuhci!UhciAbortAsyncTransfer+0xf:
f9c674c9 8b7d0c mov edi,dword ptr [ebp+0Ch]
f9c674cc 8b4748 mov eax,dword ptr [edi+48h]
f9c674cf 6a00 push 0
f9c674d1 ff7510 push dword ptr [ebp+10h]
f9c674d4 bb01000010 mov ebx,10000001h
f9c674d9 50 push eax
f9c674da 687461415f push 5F416174h
f9c674df 53 push ebx
f9c674e0 ff7508 push dword ptr [ebp+8]
f9c674e3 c645ff00 mov byte ptr [ebp-1],0
f9c674e7 8945f4 mov dword ptr [ebp-0Ch],eax
f9c674ea ff15a485c6f9 call dword ptr [usbuhci!RegistrationPacket+0x104 (f9c685a4)]
f9c674f0 8b4758 mov eax,dword ptr [edi+58h]
f9c674f3 8bf0 mov esi,eax
f9c674f5 eb0e jmp usbuhci!UhciAbortAsyncTransfer+0x4b (f9c67505)
> f9c674f7 8b4e18 mov ecx,dword ptr [esi+18h] <<<=== jump target from below is here
f9c674fa 3b4d10 cmp ecx,dword ptr [ebp+10h]
f9c674fd 740a je usbuhci!UhciAbortAsyncTransfer+0x4f (f9c67509) <<<=== found the pointer of interest
f9c674ff 8975f8 mov dword ptr [ebp-8],esi
f9c67502 8b7624 mov esi,dword ptr [esi+24h]
f9c67505 85f6 test esi,esi
f9c67507 75ee jne usbuhci!UhciAbortAsyncTransfer+0x3d (f9c674f7) <<<=== break out of loop on NULL
f9c67509 8b4e08 mov ecx,dword ptr [esi+8] <<<=== use the pointer just determined to be NULL
f9c6750c c1e913 shr ecx,13h
The first obvious thing is that regardless of whether the jump is taken after the test of esi at 0xf9c67505, esi is going to be deref’ed either by the next instruction or by the jump target which is just above. My crash happens to be at 0xf9c67509 and esi is NULL.
From the looks of things, a list is being scanned and there is an assumption (bug?) that the pointer of interest will be found and the loop will exit with a good pointer since there is not a test after breaking out and before using the pointer. FWIW, this is running under a spinlock acquired a few call frames earlier.
The version of the driver is “5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)”.
Call stack:
kd> k
*** Stack trace for last set context - .thread/.cxr resets it
ChildEBP RetAddr
f9e63c74 f9c651fb usbuhci!UhciAbortAsyncTransfer+0x4f
f9e63c98 f962d29b usbuhci!UhciAbortTransfer+0x3d
f9e63ce4 f962d563 USBPORT!USBPORT_DmaEndpointPaused+0x263
f9e63d10 f962f98c USBPORT!USBPORT_DmaEndpointWorker+0x149
f9e63d38 f963341a USBPORT!USBPORT_CoreEndpointWorker+0x6d2
f9e63d7c f962bfc0 USBPORT!USBPORT_Worker+0x212
f9e63dac 805c4a28 USBPORT!USBPORT_WorkerThread+0x12a
f9e63ddc 80540fa2 nt!PspSystemThreadStartup+0x34
00000000 00000000 nt!KiThreadStartup+0x16
Any ideas on how to determine if our code has caused an assumption to be violated or determine if this is a bug in the USB driver?
Thanks,
Tom