PREfast problem

Hi,

when I ran PREfast on my code I got a lot IRQL errors (probable Interrupt related).
I ran PREfast on the PCIDRV sample and on the PLX9x5x sample and the same defects are logged by PREfast.
The defects are (from the PCIDRV sample):
wdfinterrupt.h(278) : warning 28104: The Interrupt that should have been acquired before function exit was not acquired…
wdfinterrupt.h(278) : warning 28158: No IRQL was saved into ‘Interrupt’…
wdfinterrupt.h(299) : warning 28103: Leaking the Interrupt stored in ‘Interrupt’…
wdfinterrupt.h(299) : warning 28157: The IRQL in ‘Interrupt’ was never restored…
wdfsync.h(184) : warning 28104: The SpinLock that should have been acquired before function exit was not acquired.
wdfsync.h(184) : warning 28158: No IRQL was saved into ‘SpinLock’.
wdfsync.h(205) : warning 28103: Leaking the SpinLock stored in ‘SpinLock’.
wdfsync.h(205) : warning 28157: The IRQL in ‘SpinLock’ was never restored.
isrdpc.c(427) : warning 28167: The function ‘NICCheckForHang’ changes the IRQL and does not restore the IRQL before it exits. It should be annotated to reflect the change or the IRQL should be restored. IRQL was last set at line 511.
Found in function ‘NICCheckForHang’
Path includes 12 statements on the following lines:
448 453 461 470 481 483 497 500 505 511 513 515

… and a few more

I get the same errors with my code.
The command to run PREfast is: prefast build -cZ
WDK version: 6000
OS: XP SP2
TargetOS: XP 32-bit

Is there something wrong with the sample code and my code, is there a bug in PREfast, and what do these messages mean? (as can be seen, the errors are detected in WDF header files).

Thanks,

Kurt

I can’t say that I have ever run prefast on this particular driver, but
there are, or at least were in the recent past, drivers in the WDK that
do not build cleanly under prefast.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@barco.com
Sent: Friday, July 27, 2007 06:30
To: Windows System Software Devs Interest List
Subject: [ntdev] PREfast problem

Hi,

when I ran PREfast on my code I got a lot IRQL errors (probable
Interrupt related).
I ran PREfast on the PCIDRV sample and on the PLX9x5x sample and the
same defects are logged by PREfast.
The defects are (from the PCIDRV sample):
wdfinterrupt.h(278) : warning 28104: The Interrupt that should have been
acquired before function exit was not acquired…
wdfinterrupt.h(278) : warning 28158: No IRQL was saved into
‘Interrupt’…
wdfinterrupt.h(299) : warning 28103: Leaking the Interrupt stored in
‘Interrupt’…
wdfinterrupt.h(299) : warning 28157: The IRQL in ‘Interrupt’ was never
restored…
wdfsync.h(184) : warning 28104: The SpinLock that should have been
acquired before function exit was not acquired.
wdfsync.h(184) : warning 28158: No IRQL was saved into ‘SpinLock’.
wdfsync.h(205) : warning 28103: Leaking the SpinLock stored in
‘SpinLock’.
wdfsync.h(205) : warning 28157: The IRQL in ‘SpinLock’ was never
restored.
isrdpc.c(427) : warning 28167: The function ‘NICCheckForHang’ changes
the IRQL and does not restore the IRQL before it exits. It should be
annotated to reflect the change or the IRQL should be restored. IRQL was
last set at line 511.
Found in function ‘NICCheckForHang’
Path includes 12 statements on the following lines:
448 453 461 470 481 483 497 500 505 511 513 515

… and a few more

I get the same errors with my code.
The command to run PREfast is: prefast build -cZ
WDK version: 6000
OS: XP SP2
TargetOS: XP 32-bit

Is there something wrong with the sample code and my code, is there a
bug in PREfast, and what do these messages mean? (as can be seen, the
errors are detected in WDF header files).

Thanks,

Kurt


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

There is a problem with these annotations in the headers as well as a slight tool problem in the 6000 WDK, so you can ignore these issues for now. These problems have been solved for the next WDK release, you can try the 6001 WDK with the fixed tools and headers.

d

Thank you Doron, I am feeling more comfortable now.
Is the WDK 6001 production ready?
I need to develop for XP SP2 32- and 64-bit and for Vista 32- and 64-bit.

If you’re going to use WDK, then you can’t use 6001 unless you’re going
to install on Server 2008 (and maybe LH3). I don’t recall if you are
using it or not, but having been burnt by this myself, I thought I would
throw it in.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@barco.com
Sent: Friday, July 27, 2007 14:03
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] PREfast problem

Thank you Doron, I am feeling more comfortable now.
Is the WDK 6001 production ready?
I need to develop for XP SP2 32- and 64-bit and for Vista 32- and
64-bit.


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

Martin,

I think you meant WDF in the first sentenance. I am using 6001 quite
sucessfully for a WDM driver.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Martin O’Brien” wrote in message
news:xxxxx@ntdev…
If you’re going to use WDK, then you can’t use 6001 unless you’re going
to install on Server 2008 (and maybe LH3). I don’t recall if you are
using it or not, but having been burnt by this myself, I thought I would
throw it in.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@barco.com
Sent: Friday, July 27, 2007 14:03
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] PREfast problem

Thank you Doron, I am feeling more comfortable now.
Is the WDK 6001 production ready?
I need to develop for XP SP2 32- and 64-bit and for Vista 32- and
64-bit.


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

Thanks MM. I definitely need a driver for XP and Vista, so 6001 is a no-go.
Does anybody know of a list of known problems (or false positives) with PREfast (WDK 6000)? Are there any known workarounds, like disabling certain warnings, or hacking the responsible header files? It would help to enhance my sleep :slight_smile:

Are there any known workarounds, like disabling certain warnings […]?
Yes, there is such a pragma:
http://www.osronline.com/showThread.cfm?link=79827

Don:

Thanks. Indeed you are correct. All those acronyms.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Friday, July 27, 2007 14:32
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] PREfast problem

Martin,

I think you meant WDF in the first sentenance. I am using 6001
quite
sucessfully for a WDM driver.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Martin O’Brien” wrote in message
news:xxxxx@ntdev…
If you’re going to use WDK, then you can’t use 6001 unless you’re going
to install on Server 2008 (and maybe LH3). I don’t recall if you are
using it or not, but having been burnt by this myself, I thought I would
throw it in.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@barco.com
Sent: Friday, July 27, 2007 14:03
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] PREfast problem

Thank you Doron, I am feeling more comfortable now.
Is the WDK 6001 production ready?
I need to develop for XP SP2 32- and 64-bit and for Vista 32- and
64-bit.


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

In a word “No.” – It is a beta release.

BTW, if anybody’s interested in installing the lastest documentation-updates for the WDK, you can get them here:

http:

The good news is that the doc team is now regularly releasing updated docs… YAY DOC TEAM!!!

Peter
OSR</http:>

MAKE SURE THAT YOU READ EITHER DON’S COMMENT ON MY POST OR MY RESPONSE
TO HIS!!! I accidently typed “WDK” when I meant “WDF.” That is, WDF
drivers built with the 6001 WDK only work on Server 2008; other drivers
will work fine on Vista, et. c. Sorry about that. Just too many
similar acronyms for my fingers sometimes.

In my opinion, PREFast makes some tedious work for you, but the effort
is well worth it. You just have to go through them an evaluate them one
by one, disabling them with #pragma or what not if you don’t think that
they are valid. In my experience, most of them are valid, and many of
those aren’t can be recoded easily in a way that eliminates the warning.
While this is till irritating, I prefer it to a bunch of conditional
stuff. In addition to these, I seem to recall Doron saying something
about there being actual issues with the headers; I don’t know what they
are, the last thing on the face of the planet that you ever want do for
any reason is to modify the WDK headers. If you must go that route,
make it explicit by creating new copies with different names, which is
still a terrible, terrible idea.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@barco.com
Sent: Friday, July 27, 2007 14:47
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] PREfast problem

Thanks MM. I definitely need a driver for XP and Vista, so 6001 is a
no-go.
Does anybody know of a list of known problems (or false positives) with
PREfast (WDK 6000)? Are there any known workarounds, like disabling
certain warnings, or hacking the responsible header files? It would
help to enhance my sleep :slight_smile:


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

xxxxx@Microsoft.com wrote:

There is a problem with these annotations in the headers as well as a slight tool problem in the 6000 WDK, so you can ignore these issues for now. These problems have been solved for the next WDK release, you can try the 6001 WDK with the fixed tools and headers.

I just ran in to a problem where prefast is giving the following warning
when I use WdfInterruptAcquireLock/WdfInterruptReleaseLock in a function:

device.cpp(523) : warning 28167: The function ‘foo’ changes the IRQL and
does not restore the IRQL before it exits. It should be annotated to
reflect the change or the IRQL should be restored. IRQL was last set at
line 526.

Is this a symptom of the same thing (i.e. annotations in the WDF
headers)? Is there a way I can annotate my code to eliminate the
warning, or do I just need to suppress it with a #pragma?

Cheers,

– mkj


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________

Mike,

You can annotate your code, the best reference is the PreFast chapter
in the Microsoft WDF book. Also, the following paper is pretty good
http://www.microsoft.com/whdc/DevTools/tools/annotations.mspx. This is
well worth doing, PreFast can find a lot of problems for you.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

“Michael Jones” wrote in message
news:xxxxx@ntdev…
> xxxxx@Microsoft.com wrote:
>> There is a problem with these annotations in the headers as well as a
>> slight tool problem in the 6000 WDK, so you can ignore these issues for
>> now. These problems have been solved for the next WDK release, you can
>> try the 6001 WDK with the fixed tools and headers.
>
> I just ran in to a problem where prefast is giving the following warning
> when I use WdfInterruptAcquireLock/WdfInterruptReleaseLock in a function:
>
> device.cpp(523) : warning 28167: The function ‘foo’ changes the IRQL and
> does not restore the IRQL before it exits. It should be annotated to
> reflect the change or the IRQL should be restored. IRQL was last set at
> line 526.
>
> Is this a symptom of the same thing (i.e. annotations in the WDF
> headers)? Is there a way I can annotate my code to eliminate the
> warning, or do I just need to suppress it with a #pragma?
>
> Cheers,
>
> – mkj
>
> //
> // Michael K. Jones
> // Stone Hill Consulting, LLC
> // http://www.stonehill.com
> //

>

I’ve been sold on PreFast for some time now. I was a bit surprised to
find that KMDF doesn’t come up clean when run through PreFast; but it’s
good to know it has been corrected in the next release.

However, I’m still stuck building with the current release (KMDF 1.5,
WDK 6000). The WDF book does indeed have a great chapter on
annotations; but when I tried to add __drv_out and __drv_savesIRQL, I
get “undeclared identifier” errors from the compiler.

I did #include “driverspecs.h”, but that didn’t help. I greped the DDK
include tree for these symbols, and they don’t appear anywhere. In
fact, I greped for “__drv”, and only came up with a few (that aren’t
mentioned in the book).

What am I doing wrong?

–mkj

Don Burn wrote:

Mike,

You can annotate your code, the best reference is the PreFast chapter
in the Microsoft WDF book. Also, the following paper is pretty good
http://www.microsoft.com/whdc/DevTools/tools/annotations.mspx. This is
well worth doing, PreFast can find a lot of problems for you.


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________

I’ve had this issue with ntspecstrings appearing in multiple locations,
and the wrong one was being picked up first.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Jones
Sent: Saturday, July 28, 2007 08:55
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] PREfast problem

I’ve been sold on PreFast for some time now. I was a bit surprised to
find that KMDF doesn’t come up clean when run through PreFast; but it’s
good to know it has been corrected in the next release.

However, I’m still stuck building with the current release (KMDF 1.5,
WDK 6000). The WDF book does indeed have a great chapter on
annotations; but when I tried to add __drv_out and __drv_savesIRQL, I
get “undeclared identifier” errors from the compiler.

I did #include “driverspecs.h”, but that didn’t help. I greped the DDK
include tree for these symbols, and they don’t appear anywhere. In
fact, I greped for “__drv”, and only came up with a few (that aren’t
mentioned in the book).

What am I doing wrong?

–mkj

Don Burn wrote:

Mike,

You can annotate your code, the best reference is the PreFast
chapter
in the Microsoft WDF book. Also, the following paper is pretty good
http://www.microsoft.com/whdc/DevTools/tools/annotations.mspx. This
is
well worth doing, PreFast can find a lot of problems for you.


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________


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

The __drv* annotations are in the post 6000 WDK, not in the current WDK.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Jones
Sent: Saturday, July 28, 2007 5:55 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] PREfast problem

I’ve been sold on PreFast for some time now. I was a bit surprised to
find that KMDF doesn’t come up clean when run through PreFast; but it’s
good to know it has been corrected in the next release.

However, I’m still stuck building with the current release (KMDF 1.5,
WDK 6000). The WDF book does indeed have a great chapter on
annotations; but when I tried to add __drv_out and __drv_savesIRQL, I
get “undeclared identifier” errors from the compiler.

I did #include “driverspecs.h”, but that didn’t help. I greped the DDK
include tree for these symbols, and they don’t appear anywhere. In
fact, I greped for “__drv”, and only came up with a few (that aren’t
mentioned in the book).

What am I doing wrong?

–mkj

Don Burn wrote:

Mike,

You can annotate your code, the best reference is the PreFast
chapter
in the Microsoft WDF book. Also, the following paper is pretty good
http://www.microsoft.com/whdc/DevTools/tools/annotations.mspx. This
is
well worth doing, PreFast can find a lot of problems for you.


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________


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

Right now #pragmas are the way to go. You could also comment out the
offending annotations in the header and that way when you get the next
WDK you don’t have to modify your code, but touching the WDK headers
might see a bit frankenbuild’ish to some.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Jones
Sent: Friday, July 27, 2007 5:19 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] PREfast problem

xxxxx@Microsoft.com wrote:

There is a problem with these annotations in the headers as well as a
slight tool problem in the 6000 WDK, so you can ignore these issues for
now. These problems have been solved for the next WDK release, you can
try the 6001 WDK with the fixed tools and headers.

I just ran in to a problem where prefast is giving the following warning

when I use WdfInterruptAcquireLock/WdfInterruptReleaseLock in a
function:

device.cpp(523) : warning 28167: The function ‘foo’ changes the IRQL and

does not restore the IRQL before it exits. It should be annotated to
reflect the change or the IRQL should be restored. IRQL was last set at
line 526.

Is this a symptom of the same thing (i.e. annotations in the WDF
headers)? Is there a way I can annotate my code to eliminate the
warning, or do I just need to suppress it with a #pragma?

Cheers,

– mkj


//
// Michael K. Jones
// Stone Hill Consulting, LLC
// http://www.stonehill.com
//_______________________________________________


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