I have the following code that is misbehaving with a 0xD1 (9, 2, 1, x)
BSoD, and the debugger says this is happening when referencing the Blink
of a LIST_ENTRY, where the Flink of the previous entry has been set to 1
instead of a pointer. I peppered a bunch of ASSERTS around to catch when
this happens and it’s happening after a KdPrint as per code below:
#define FUNCTION_MSG(…) KdPrint((__DRIVER_NAME " " VA_ARGS))
#define NBL_LIST_ENTRY_FIELD MiniportReserved[0]
#define NBL_LIST_ENTRY(_nbl)
(*(PLIST_ENTRY)&(_nbl)->NBL_LIST_ENTRY_FIELD)
while (!IsListEmpty(&nbl_head))
{
PNET_BUFFER_LIST nbl;
nbl_entry = RemoveHeadList(&nbl_head);
ASSERT((ULONG_PTR)nbl_head.Flink->Flink != 1);
ASSERT((ULONG_PTR)nbl_head.Blink->Flink != 1);
FUNCTION_MSG(" %p retrieved flink = %p, blink = %p\n", nbl_entry,
nbl_entry->Flink, nbl_entry->Blink);
ASSERT((ULONG_PTR)nbl_head.Flink->Flink != 1); <----- this assert
fails
ASSERT((ULONG_PTR)nbl_head.Blink->Flink != 1);
nbl = CONTAINING_RECORD(nbl_entry, NET_BUFFER_LIST,
NBL_LIST_ENTRY_FIELD);
ASSERT((ULONG_PTR)nbl_head.Flink->Flink != 1);
ASSERT((ULONG_PTR)nbl_head.Blink->Flink != 1);
nbl->Status = NDIS_STATUS_SUCCESS;
ASSERT((ULONG_PTR)nbl_head.Flink->Flink != 1);
ASSERT((ULONG_PTR)nbl_head.Blink->Flink != 1);
FUNCTION_MSG(“A %p\n”, nbl);
ASSERT((ULONG_PTR)nbl_head.Flink->Flink != 1);
ASSERT((ULONG_PTR)nbl_head.Blink->Flink != 1);
NdisMSendNetBufferListsComplete(xi->adapter_handle, nbl,
NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL);
ASSERT((ULONG_PTR)nbl_head.Flink->Flink != 1);
ASSERT((ULONG_PTR)nbl_head.Blink->Flink != 1);
}
nbl_head is a local variable containing a list of packets that have been
retrieved from the io ring of the hardware (xen virtual network device
actually) and I gather them all with a lock held and then indicate them
after releasing the lock (the code above).
The fact that the only thing that happens before the breakage is a
KdPrint presumably means that I’ve previously corrupted memory, but
tracking it down is proving to be an exercise in frustration. Aside from
the verifier (which isn’t helping), are there any other tricks I can use
to find out where my bug is?
Thanks
James