Re: [ntdev] Using SAL annotations

I for one will be very interested in the outcome. We use SAL extensively and it is useful for describing the function contract even without the analysis backend, but obviously serious bugs limit its usefulness

Sent from Surface Pro

From: Gurzou Alexandru
Sent: ‎Thursday‎, ‎July‎ ‎30‎, ‎2015 ‎4‎:‎25‎ ‎AM
To: Windows System Software Devs Interest List

I’ve posted an issue on connect https://connect.microsoft.com/VisualStudio/Feedback/Details/1605316 and Microsoft said they’re looking into it. I will inform you of the final resolution.

On 29 July 2015 at 20:03, Scott Noone wrote:

I can confirm that you’re not insane, I can reproduce your observed behavior in both VS2013 and VS2015.

Looks to me like the MyFunc0 annotation should certainly work in catching in the error. The Windows headers use this syntax (see RtlStringCchCopyW), so I feel like I’m missing something. Just don’t see it here though.

-scott
OSR
@OSRDrivers

“Gurzou Alexandru” wrote in message news:xxxxx@ntdev…

Hello,

I just started diving in into SAL annotations and I noticed what seems like a bug to me. I have the following functions:

void
MyFunc0(
Out_writes(NumberOfEntries) DWORD* ArrayOfStructs,
In DWORD NumberOfEntries
)
{
DWORD i;

for( i = 0; i <= NumberOfEntries; ++i )
{
ArrayOfStructs[i] = i;
}
}

void
MyFunc1(
Out_writes_bytes(sizeof(DWORD)NumberOfEntries) DWORD ArrayOfStructs,
In DWORD NumberOfEntries
)
{
DWORD i;

for( i = 0; i <= NumberOfEntries; ++i )
{
ArrayOfStructs[i] = i;
}
}

void
MyFunc2(
Out_writes_all(NumberOfEntries) DWORD* ArrayOfStructs,
In DWORD NumberOfEntries
)
{
DWORD i;

for( i = 0; i <= NumberOfEntries; ++i )
{
ArrayOfStructs[i] = i;
}
}

void
MyFunc3(
Out_writes_bytes_all(sizeof(DWORD)NumberOfEntries) DWORD ArrayOfStructs,
In DWORD NumberOfEntries
)
{
DWORD i;

for( i = 0; i <= NumberOfEntries; ++i )
{
ArrayOfStructs[i] = i;
}
}

Intentionally I have written the loop from 0 to NumberOfEntries to see off by one reports from the static analyzer. Unfortunately the only place where the warning appears is MyFunc1.

I’ve run the analyzer on these functions using Visual Studio 2013 in a user mode, kernel mode and in a native project and the same results appear everywhere. The rule set used by the analyzer was: “Microsoft All Rules” which as I understand should contain all verifier checks.

Am I missing something or is this a bug?

I hope this is the correct list for posting these kind of issues.

Thanks!


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

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 Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers 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