Re: Compiler bug in the DDK--be aware of it
- From: "Gary G. Little" <gary.g.little@xxxxxxxxxxx>
- Date: Tue, 25 Jul 2006 09:36:54 -0500
No one ever said that the DDK compiler was perfect, just that it was the
only supported compiler for device driver development. That still holds
true. So you found a bug? Are there others? Probably. I'm really glad that
the VS 2005 compiler does not have that bug, but I wander what other bugs it
does have? Does the VS compiler have equivalent bugs? I am very sure it
does. Oh yeah ... the biggest reason for not using the VS compiler ... it's
not a compiler supported by Microsoft for DDK work.
Serious? A showstopper? I think not. In 10 years of writting driver code,
that is the first time I have ever seen InterlockedOr used. In that time
frame I've found other compiler anomalies. In the 30 years I've been doing
this I've found them in every compiler or assembler I've ever used. I simply
adjust for them, or fix them if I am responsible for the build tools.
But thank you for publishing your findings, I'll be sure to not use
InterlockedOr, and use one of a dozen other ways to do the same thing.
--
The personal opinion of
Gary G. Little
<440gtx@xxxxxxxxx> wrote in message
news:1153830650.166359.4900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi guys, I ran into a compiler bug in the latest ddk that is very
serious. I have a piece of code I want to execute exactly one time, but
discovered it gets run every single time. It is written as follows:
void func(void)
{
static LONG Init = 0;
if (InterlockedOr(&Init, 1) == 0)
{
...do one time stuff here...
}
}
The problem is the inner code executes every single time the function
is invoked. I traced it down to a bug in the compiler. I then
recompiled the driver using the Visual Studio 2005 compiler and the
problem was fixed. I have attached the code each generated below. I'm
now concerned about shipping any future drivers compiled using the DDK
build environment because I don't know what all functions besides this
particular example would generate corrupt code.
;------------------------------------;
; Windows 2003 DDK SP1 (3790.1830)
;------------------------------------;
mov ecx, 1
mov edx, OFFSET FLAT:?Init
mov eax, DWORD PTR [edx]
$L14033:
mov esi, eax
or esi, ecx
lock cmpxchg DWORD PTR [edx], esi
jne $L14033
jne $L14011
;------------------------------------
; Visual Studio 2005
;------------------------------------
mov ecx, 1
mov edx, OFFSET ?Init
mov eax, DWORD PTR [edx]
$LN4
mov esi, eax
or esi, ecx
lock cmpxchg DWORD PTR [edx], esi
jne SHORT $LN4
test eax, eax ; <---------fixed
jne SHORT $LN2
.
- Follow-Ups:
- Re: Compiler bug in the DDK--be aware of it
- From: BubbaGump
- Re: Compiler bug in the DDK--be aware of it
- Prev by Date: Re: Compiler bug in the DDK--be aware of it
- Next by Date: Re: Question about SetupDiGetClassDevs and SetupDiEnumDeviceInterf
- Previous by thread: Re: Compiler bug in the DDK--be aware of it
- Next by thread: Re: Compiler bug in the DDK--be aware of it
- Index(es):
Relevant Pages
|
Loading