Hello,
when calling KeWaitForSingleObject at PASSIVE_LEVEL to acquire a mutex
like this I experience a very strange problem:
KeWaitForSingleObject(&devext->mutex, Executive, KernelMode, FALSE, NULL)
Initially everything is ok, the thread remains at PASSIVE_LEVEL as
expected. But after several thousend invokations (not every time the same
count, it appears to happen randomly) KeWaitForSingleObject
raises the IRQL to APC_LEVEL. The following KeReleaseMutex doesn’t reset
the IRQL. Even after returning to user mode the thread continues to run
at APC_LEVEL. This happens on both NT4 and W2K. The return value is 0.
I checked it with the debugger and with asserts, and I am sure that it
indeed happens inside KeWaitForSingleObject. The code is at the start
of the IRP_MJ_DEVICE_CONTROL function. Using a fastmutex is not an option,
because the driver may need to call other drivers and wait for completion
(but in the test run causing the problem it doesn’t call other drivers).
Any idea what could be causing KeWaitForSingleObject to raise the IRQL?
I am not aware of any source that describes this behaviour.
Regards,
Harald