ObDereferenceObject never returns

This is happening in my code.
under what condition, ObDereferenceObject never returns, and is there any way to check the reason?

Call stack under the Ob call? What type of object are you dereferencing? For instance, a deref on a file object can lead to the MJ_CLOSE irp being sent to the underlying stack and it could be stuck in the driver.

What is the stack trace?
An invalid handle passed is the most common reason.
Also, the ObMgr might need to wait on an event, that would never get
satisfied in your case (e.g. you are holding the lock)

Deja.

This is happening in my code.

under what condition, ObDereferenceObject never returns, and is there any
way to check the reason?


Reply to this email directly or follow the link below to check it out:
https://community.osr.com/discussion/291703/obdereferenceobject-never-returns

Check it out:
https://community.osr.com/discussion/291703/obdereferenceobject-never-returns

Thanks @Dejan_Maksimovic and @Doron_Holan
the type of object is FILE_OBJECT.
for the call stack, as it is WDDM related and so
mywddmminiportDriver!UnloadMyminiportDriver+0x13
dxgkrnl!DpiDxgkDdiUnload+0x33 [onecoreuap\windows\core\dxkernel\dxgkrnl\port\dpetw.cxx @ 447]
dxgkrnl!DpiCleanup+0xaf [onecoreuap\windows\core\dxkernel\dxgkrnl\port\dpport.cxx @ 3193]
dxgkrnl!DpiDriverUnload+0xb [onecoreuap\windows\core\dxkernel\dxgkrnl\port\dpport.cxx @ 3229]
nt!IopUnloadDriver+0x20f [minkernel\ntos\io\iomgr\loadunld.c @ 571]
nt!PnpUnloadAttachedDriver+0xa6 [minkernel\ntos\io\pnpmgr\remove.c @ 3724]
nt!PnpRemoveLockedDeviceNode+0x240 [minkernel\ntos\io\pnpmgr\remove.c @ 1501]
nt!PnpDeleteLockedDeviceNode+0x8b [minkernel\ntos\io\pnpmgr\remove.c @ 584]
nt!PnpDeleteLockedDeviceNodes+0x76 [minkernel\ntos\io\pnpmgr\remove.c @ 1712]
nt!PipRemoveDevicesInRelationList+0x8d [minkernel\ntos\io\pnpmgr\remove.c @ 474]
nt!PnpDelayedRemoveWorker+0x114 [minkernel\ntos\io\pnpmgr\remove.c @ 363]
nt!PnpChainDereferenceComplete+0xfd [minkernel\ntos\io\pnpmgr\remove.c @ 285]
nt!PnpIsChainDereferenced+0xac [minkernel\ntos\io\pnpmgr\eventremove.c @ 1521]
nt!PnpProcessQueryRemoveAndEject+0x2a2 [minkernel\ntos\io\pnpmgr\event.c @ 2896]
nt!PnpProcessTargetDeviceEvent+0xea [minkernel\ntos\io\pnpmgr\event.c @ 3351]
nt!PnpDeviceEventWorker+0x2d8 [minkernel\ntos\io\pnpmgr\event.c @ 1821]
nt!ExpWorkerThread+0x105 [minkernel\ntos\ex\worker.c @ 4315]
nt!PspSystemThreadStartup+0x55 [minkernel\ntos\ps\psexec.c @ 9310]
nt!KiStartSystemThread+0x2a [minkernel\ntos\ke\amd64\threadbg.asm @ 83]

Sooooo… you’re hanging in your WDDM driver’s unload entry point…

Peter