Puzzling error when calling WdfWorkItemCreate

Hello!

I’m having trouble with a seemingly trivial WDF task. I want to create a

work item, but when calling WdfWorkItemCreate I get a blue screen. The code I use to create the work item looks like this:

struct ReadWorkerContext

{

WDFIOTARGET SerialPort;

ReadMessageContext* ReadMessageContext;

};

VOID ReadWorker(WDFWORKITEM WorkItem)

{

ReadWorkerContext* readWorkerContext = GetReadWorkerContext(WorkItem);

CreateAndSendReadRequest(readWorkerContext->SerialPort,

readWorkerContext->ReadMessageContext);

WdfObjectDelete(WorkItem);

}

NTSTATUS CreateReadWorker(WDFIOTARGET SerialPort, ReadMessageContext* ReadMessageContext)

{

WDF_OBJECT_ATTRIBUTES attributes;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);

attributes.ParentObject = WdfIoTargetGetDevice(SerialPort);

WDF_WORKITEM_CONFIG config;

WDF_WORKITEM_CONFIG_INIT(&config, ReadWorker);

WDFWORKITEM workItem ;

NTSTATUS status = WdfWorkItemCreate(&config, &attributes, &workItem);

TDS_CHECK_STATUS(status, “could not create work item”);

WdfWorkItemEnqueue(workItem);

return STATUS_SUCCESS;

}

I would think that this would be very straight forward. However, I get a blue screen when WdfWorkItemCreate is called. Loading the memory dump in WinDbg I get this information:

[snip]

BugCheck 7E, {80000003, 80526fbc, f9df3614, f9df3310}

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

Probably caused by : Wdf01000.sys ( Wdf01000!FxObject::_GetEffectiveLock+87 )

[snip]

STACK_TEXT:

f9df36d8 f74d0366 8167c4a8 f750d7ac f9df3794 nt!DbgBreakPoint

f9df36ec f74dacb9 81144880 811448b4 00000003 Wdf01000!FxObject::_GetEffectiveLock+0x87

f9df3724 f74daefa f9df3794 f9df37b8 f9df37b4 Wdf01000!FxWorkItem::Initialize+0x86

f9df3740 f74bd1c0 816981a8 f9df37b8 f9df3794 Wdf01000!FxWorkItem::Create+0x4b

f9df3764 f9cbcb9d 816981a8 f9df37b8 f9df3794 Wdf01000!imp_WdfWorkItemCreate+0x483

f9df377c f9cbcf4c f9df37b8 f9df3794 f9df37b4 hello!WdfWorkItemCreate+0x1d [c:\winddk\6000\inc\wdf\kmdf\10\wdfworkitem.h @ 98]

f9df37c4 f9cbd212 7eb2e220 817abd48 81144a48 hello!`anonymous namespace’::CreateReadWorker+0x3c [c:\source\hypercom\message.cpp @ 128]

f9df3808 f9cbfe10 7eebb778 00000000 003f005c hello!StartMessageReading+0xb2 [c:\source\hypercom\message.cpp @ 208]

f9df3920 f74f707c 7eebb778 7e7e1c50 7e7cd4a8 hello!UsbSamp_EvtDevicePrepareHardware+0x210 [c:\source\hypercom\device.cpp @ 313]

f9df3940 f74f73ae f9df395b 00000008 8111a048 Wdf01000!FxPkgPnp::PnpPrepareHardware+0x7c

f9df395c f74f6245 8111a048 f750f260 8111a048 Wdf01000!FxPkgPnp::PnpEventHardwareAvailable+0x6f

f9df3984 f74f6fa0 00000108 8111a0e8 8111a048 Wdf01000!FxPkgPnp::PnpEnterNewState+0x15c

[snip]

Does anyone here have any ideas as to why this doesn’t work? =)

I have verified that the SerialPort handle has the same value as when it was created with WdfIoTargetCreate. I have also verified that the handle returned by WdfIoTargetGetDevice has the same value as the WDFDEVICE handle passed to EvtDevicePrepareHardware.

Any input on this would be greatly appreciated!

Regards,

Mattias

What are you setting the sync scope and execution level when you create the WDFDEVICE? Set config. AutomaticSerialization = FALSE and then this should work (I think). You also need to call

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, ReadWorkerContext);

Otherwise the call to GetReadWorkerContext will return null

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mattias Br?ndstr?m
Sent: Thursday, February 07, 2008 8:11 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Puzzling error when calling WdfWorkItemCreate

Hello!

I’m having trouble with a seemingly trivial WDF task. I want to create a

work item, but when calling WdfWorkItemCreate I get a blue screen. The code I use to create the work item looks like this:

struct ReadWorkerContext

{

WDFIOTARGET SerialPort;

ReadMessageContext* ReadMessageContext;

};

VOID ReadWorker(WDFWORKITEM WorkItem)

{

ReadWorkerContext* readWorkerContext = GetReadWorkerContext(WorkItem);

CreateAndSendReadRequest(readWorkerContext->SerialPort,

readWorkerContext->ReadMessageContext);

WdfObjectDelete(WorkItem);

}

NTSTATUS CreateReadWorker(WDFIOTARGET SerialPort, ReadMessageContext* ReadMessageContext)

{

WDF_OBJECT_ATTRIBUTES attributes;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);

attributes.ParentObject = WdfIoTargetGetDevice(SerialPort);

WDF_WORKITEM_CONFIG config;

WDF_WORKITEM_CONFIG_INIT(&config, ReadWorker);

WDFWORKITEM workItem ;

NTSTATUS status = WdfWorkItemCreate(&config, &attributes, &workItem);

TDS_CHECK_STATUS(status, “could not create work item”);

WdfWorkItemEnqueue(workItem);

return STATUS_SUCCESS;

}

I would think that this would be very straight forward. However, I get a blue screen when WdfWorkItemCreate is called. Loading the memory dump in WinDbg I get this information:

[snip]

BugCheck 7E, {80000003, 80526fbc, f9df3614, f9df3310}

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

Probably caused by : Wdf01000.sys ( Wdf01000!FxObject::_GetEffectiveLock+87 )

[snip]

STACK_TEXT:

f9df36d8 f74d0366 8167c4a8 f750d7ac f9df3794 nt!DbgBreakPoint

f9df36ec f74dacb9 81144880 811448b4 00000003 Wdf01000!FxObject::_GetEffectiveLock+0x87

f9df3724 f74daefa f9df3794 f9df37b8 f9df37b4 Wdf01000!FxWorkItem::Initialize+0x86

f9df3740 f74bd1c0 816981a8 f9df37b8 f9df3794 Wdf01000!FxWorkItem::Create+0x4b

f9df3764 f9cbcb9d 816981a8 f9df37b8 f9df3794 Wdf01000!imp_WdfWorkItemCreate+0x483

f9df377c f9cbcf4c f9df37b8 f9df3794 f9df37b4 hello!WdfWorkItemCreate+0x1d [c:\winddk\6000\inc\wdf\kmdf\10\wdfworkitem.h @ 98]

f9df37c4 f9cbd212 7eb2e220 817abd48 81144a48 hello!`anonymous namespace’::CreateReadWorker+0x3c [c:\source\hypercom\message.cpp @ 128]

f9df3808 f9cbfe10 7eebb778 00000000 003f005c hello!StartMessageReading+0xb2 [c:\source\hypercom\message.cpp @ 208]

f9df3920 f74f707c 7eebb778 7e7e1c50 7e7cd4a8 hello!UsbSamp_EvtDevicePrepareHardware+0x210 [c:\source\hypercom\device.cpp @ 313]

f9df3940 f74f73ae f9df395b 00000008 8111a048 Wdf01000!FxPkgPnp::PnpPrepareHardware+0x7c

f9df395c f74f6245 8111a048 f750f260 8111a048 Wdf01000!FxPkgPnp::PnpEventHardwareAvailable+0x6f

f9df3984 f74f6fa0 00000108 8111a0e8 8111a048 Wdf01000!FxPkgPnp::PnpEnterNewState+0x15c

[snip]

Does anyone here have any ideas as to why this doesn’t work? =)

I have verified that the SerialPort handle has the same value as when it was created with WdfIoTargetCreate. I have also verified that the handle returned by WdfIoTargetGetDevice has the same value as the WDFDEVICE handle passed to EvtDevicePrepareHardware.

Any input on this would be greatly appreciated!

Regards,

Mattias


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

You hit a breakpoint.

You have Kmdf verifier turned on, with break on error enabled. If you’re
going to do that, you MUST have a debugger attached. Then you can look at
the log and see what Wdf has a problem with.

  • Dan.

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mattias Br?ndstr?m
Sent: Thursday, February 07, 2008 9:11 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Puzzling error when calling WdfWorkItemCreate

Hello!

I’m having trouble with a seemingly trivial WDF task. I want to create a

work item, but when calling WdfWorkItemCreate I get a blue screen. The code
I use to create the work item looks like this:

struct ReadWorkerContext

{

WDFIOTARGET SerialPort;

ReadMessageContext* ReadMessageContext;

};

VOID ReadWorker(WDFWORKITEM WorkItem)

{

ReadWorkerContext* readWorkerContext = GetReadWorkerContext(WorkItem);

CreateAndSendReadRequest(readWorkerContext->SerialPort,

readWorkerContext->ReadMessageContext);

WdfObjectDelete(WorkItem);

}

NTSTATUS CreateReadWorker(WDFIOTARGET SerialPort, ReadMessageContext*
ReadMessageContext)

{

WDF_OBJECT_ATTRIBUTES attributes;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);

attributes.ParentObject = WdfIoTargetGetDevice(SerialPort);

WDF_WORKITEM_CONFIG config;

WDF_WORKITEM_CONFIG_INIT(&config, ReadWorker);

WDFWORKITEM workItem ;

NTSTATUS status = WdfWorkItemCreate(&config, &attributes, &workItem);

TDS_CHECK_STATUS(status, “could not create work item”);

WdfWorkItemEnqueue(workItem);

return STATUS_SUCCESS;

}

I would think that this would be very straight forward. However, I get a
blue screen when WdfWorkItemCreate is called. Loading the memory dump in
WinDbg I get this information:

[snip]

BugCheck 7E, {80000003, 80526fbc, f9df3614, f9df3310}

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

Probably caused by : Wdf01000.sys ( Wdf01000!FxObject::_GetEffectiveLock+87
)

[snip]

STACK_TEXT:

f9df36d8 f74d0366 8167c4a8 f750d7ac f9df3794 nt!DbgBreakPoint

f9df36ec f74dacb9 81144880 811448b4 00000003
Wdf01000!FxObject::_GetEffectiveLock+0x87

f9df3724 f74daefa f9df3794 f9df37b8 f9df37b4
Wdf01000!FxWorkItem::Initialize+0x86

f9df3740 f74bd1c0 816981a8 f9df37b8 f9df3794
Wdf01000!FxWorkItem::Create+0x4b

f9df3764 f9cbcb9d 816981a8 f9df37b8 f9df3794
Wdf01000!imp_WdfWorkItemCreate+0x483

f9df377c f9cbcf4c f9df37b8 f9df3794 f9df37b4 hello!WdfWorkItemCreate+0x1d
[c:\winddk\6000\inc\wdf\kmdf\10\wdfworkitem.h @ 98]

f9df37c4 f9cbd212 7eb2e220 817abd48 81144a48 hello!`anonymous
namespace’::CreateReadWorker+0x3c [c:\source\hypercom\message.cpp @ 128]

f9df3808 f9cbfe10 7eebb778 00000000 003f005c hello!StartMessageReading+0xb2
[c:\source\hypercom\message.cpp @ 208]

f9df3920 f74f707c 7eebb778 7e7e1c50 7e7cd4a8
hello!UsbSamp_EvtDevicePrepareHardware+0x210 [c:\source\hypercom\device.cpp
@ 313]

f9df3940 f74f73ae f9df395b 00000008 8111a048
Wdf01000!FxPkgPnp::PnpPrepareHardware+0x7c

f9df395c f74f6245 8111a048 f750f260 8111a048
Wdf01000!FxPkgPnp::PnpEventHardwareAvailable+0x6f

f9df3984 f74f6fa0 00000108 8111a0e8 8111a048
Wdf01000!FxPkgPnp::PnpEnterNewState+0x15c

[snip]

Does anyone here have any ideas as to why this doesn’t work? =)

I have verified that the SerialPort handle has the same value as when it was
created with WdfIoTargetCreate. I have also verified that the handle
returned by WdfIoTargetGetDevice has the same value as the WDFDEVICE handle
passed to EvtDevicePrepareHardware.

Any input on this would be greatly appreciated!

Regards,

Mattias


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Aha! Many thanks! I have queue scope synchronization set in the device and setting AutomaticSerialization = FALSE in the work item config removes the blue screen. Thanks again!

:.:: mattias


Fr?n: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] F?r Doron Holan
Skickat: den 7 februari 2008 17:28
Till: Windows System Software Devs Interest List
?mne: RE:[ntdev] Puzzling error when calling WdfWorkItemCreate

What are you setting the sync scope and execution level when you create the WDFDEVICE? Set config. AutomaticSerialization = FALSE and then this should work (I think). You also need to call

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, ReadWorkerContext);

Otherwise the call to GetReadWorkerContext will return null

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mattias Br?ndstr?m
Sent: Thursday, February 07, 2008 8:11 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Puzzling error when calling WdfWorkItemCreate

Hello!

I’m having trouble with a seemingly trivial WDF task. I want to create a

work item, but when calling WdfWorkItemCreate I get a blue screen. The code I use to create the work item looks like this:

struct ReadWorkerContext

{

WDFIOTARGET SerialPort;

ReadMessageContext* ReadMessageContext;

};

VOID ReadWorker(WDFWORKITEM WorkItem)

{

ReadWorkerContext* readWorkerContext = GetReadWorkerContext(WorkItem);

CreateAndSendReadRequest(readWorkerContext->SerialPort,

readWorkerContext->ReadMessageContext);

WdfObjectDelete(WorkItem);

}

NTSTATUS CreateReadWorker(WDFIOTARGET SerialPort, ReadMessageContext* ReadMessageContext)

{

WDF_OBJECT_ATTRIBUTES attributes;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);

attributes.ParentObject = WdfIoTargetGetDevice(SerialPort);

WDF_WORKITEM_CONFIG config;

WDF_WORKITEM_CONFIG_INIT(&config, ReadWorker);

WDFWORKITEM workItem ;

NTSTATUS status = WdfWorkItemCreate(&config, &attributes, &workItem);

TDS_CHECK_STATUS(status, “could not create work item”);

WdfWorkItemEnqueue(workItem);

return STATUS_SUCCESS;

}

I would think that this would be very straight forward. However, I get a blue screen when WdfWorkItemCreate is called. Loading the memory dump in WinDbg I get this information:

[snip]

BugCheck 7E, {80000003, 80526fbc, f9df3614, f9df3310}

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

*** No owner thread found for resource 80551360

Probably caused by : Wdf01000.sys ( Wdf01000!FxObject::_GetEffectiveLock+87 )

[snip]

STACK_TEXT:

f9df36d8 f74d0366 8167c4a8 f750d7ac f9df3794 nt!DbgBreakPoint

f9df36ec f74dacb9 81144880 811448b4 00000003 Wdf01000!FxObject::_GetEffectiveLock+0x87

f9df3724 f74daefa f9df3794 f9df37b8 f9df37b4 Wdf01000!FxWorkItem::Initialize+0x86

f9df3740 f74bd1c0 816981a8 f9df37b8 f9df3794 Wdf01000!FxWorkItem::Create+0x4b

f9df3764 f9cbcb9d 816981a8 f9df37b8 f9df3794 Wdf01000!imp_WdfWorkItemCreate+0x483

f9df377c f9cbcf4c f9df37b8 f9df3794 f9df37b4 hello!WdfWorkItemCreate+0x1d [c:\winddk\6000\inc\wdf\kmdf\10\wdfworkitem.h @ 98]

f9df37c4 f9cbd212 7eb2e220 817abd48 81144a48 hello!`anonymous namespace’::CreateReadWorker+0x3c [c:\source\hypercom\message.cpp @ 128]

f9df3808 f9cbfe10 7eebb778 00000000 003f005c hello!StartMessageReading+0xb2 [c:\source\hypercom\message.cpp @ 208]

f9df3920 f74f707c 7eebb778 7e7e1c50 7e7cd4a8 hello!UsbSamp_EvtDevicePrepareHardware+0x210 [c:\source\hypercom\device.cpp @ 313]

f9df3940 f74f73ae f9df395b 00000008 8111a048 Wdf01000!FxPkgPnp::PnpPrepareHardware+0x7c

f9df395c f74f6245 8111a048 f750f260 8111a048 Wdf01000!FxPkgPnp::PnpEventHardwareAvailable+0x6f

f9df3984 f74f6fa0 00000108 8111a0e8 8111a048 Wdf01000!FxPkgPnp::PnpEnterNewState+0x15c

[snip]

Does anyone here have any ideas as to why this doesn’t work? =)

I have verified that the SerialPort handle has the same value as when it was created with WdfIoTargetCreate. I have also verified that the handle returned by WdfIoTargetGetDevice has the same value as the WDFDEVICE handle passed to EvtDevicePrepareHardware.

Any input on this would be greatly appreciated!

Regards,

Mattias


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Dan Kyler wrote:

You hit a breakpoint.

You have Kmdf verifier turned on, with break on error enabled. If
you’re going to do that, you MUST have a debugger attached. Then you
can look at the log and see what Wdf has a problem with.

Actually, you can handle this post-morten. The Kmdf verifier is kind
enough to log everything with WPP, so you can use !wdflogdump to find
out what the complaint was.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.