Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

Kernel Mode driver error Code 38 - Failed Prior Unload.

cyberteencyberteen Member Posts: 7

Hi Everyone,

A new windows developer here. Excuse me for any mistakes!

We have a kernel mode driver which after a sequence of hibernate stress tests resulted in one of the driver module repeatedly loading and unloading.
The resulting error code on device manager is 38 - which according to MSDN is that driver prior unloading failed.

From the WPP logs, all modules seem to cleanup and unload properly. Not sure how to debug this problem

Also we have a crash dump collected after we see this error on driver. I can see the error node which failed to unload ( using the command - !devnode 0 1 or !pnptriage.)

Many other posts and articles suggest that this could point to leaked reference on Driver Object itself rather than simple memory leaks.

If turning on Object Reference Tracking is the way, how do I enable it for a particular driver ? Example only show for dll files or executables.

Appreciate any help. Thanks

Comments

  • cyberteencyberteen Member Posts: 7
    edited October 29

    I was able to gather this information to enable Object Tracking on Device Objects,
    1. Enable Gflags
    2. and keeping the pool tag as "Devi"
    3. Ignore the image name so it will consider the entire System
    4. So, when I reboot my PC, run the test, and get the Code 38 error again, Can I just run !obtrace "dev obj address" which I can get from !devnode ?

    Is this a right way to debug this particular issue of driver unload ? Let me know if any other info is required or if better approaches are available.

    Thanks

  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,465

    There's possibly a reference on the driver object. That could be from a device object or it can be something else (e.g. failing to unregister with WPP). Does your driver pass Verifier?

    -scott
    OSR

  • cyberteencyberteen Member Posts: 7

    @Scott_Noone_(OSR) said:
    There's possibly a reference on the driver object. That could be from a device object or it can be something else (e.g. failing to unregister with WPP). Does your driver pass Verifier?

    Yes. Driver verifier is enabled, but nothing is triggered.

  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,465

    Does this happen reliably? If yes, can you start removing functionality until the test case passes? Sometimes that’s the easiest way to narrow down the problem.

    -scott
    OSR

  • cyberteencyberteen Member Posts: 7

    @Scott_Noone_(OSR) , Not reliably I guess. It has been reported to happen after several hundred or even thousands of iterations of hibernate cycles.
    Further, this is on a customer's setup. So, I don't think I can take the approach to keep reducing functionality until problem is found. i.e. not feasible for customer to run so many patches in worst case.

    But I am also trying to replicate this in my internal setup. Not been successful so far. But will consider your approach if issue gets repro'd.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 24 January 2022 Live, Online
Internals & Software Drivers 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online
Developing Minifilters 23 May 2022 Live, Online