Use a request's context after the request was completed but has reference RRS feed

  • Question

  • Hi,

    I have a race condition of request. This request's context contains spinlock. Now I'm in a state that request's status is completed and its IRP is NULL but its ref count is 1 (since I incremented the reference before). In this case, can I use the spinlock belongs to this request's context? I failed with IRQL_NOT_LESS_OR_EQUAL and in the windbg I see that the spinlock is invalid (the spinlock is not NULL). does it expected behavior? if so, can I set the request's context to be NULL when I complete it in another function? should I release the context before?


    Tuesday, August 4, 2015 4:48 AM


  • is the WDFSPINLOCK a child of the WDFREQUEST (did you specify the request as the parent object when you created the WDFSPINLOCK)? when you complete a WDFREQUEST, all of the normal object cleanup rules apply, which means all of the children are cleaned up and destroyed. Taking a reference on the WDFREQUEST does not keep the state valid, it just keeps the object valid. if you want the spinlock to live longer than the request, make the WDFDEVICE or some other object the parent.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 4, 2015 6:21 AM