But why does the DDK compiler generate a reference to a system
function that is not provided with the DDK, and that is left
dangling after a perfectly valid build ? My point is this:
either that call should not be generated, or that function
should be provided in some library and linked in properly. But
if they generate a call to some implementation of __chkstk()
which they don’t provide, maybe I’m justified in calling it a
bug.
I’m not worried about that function being injected in the
checked build, but I will not be happy if I see it inserted in
the free build. I have a deep philosophical and personal issue
with this thing: it’s my code and if I find out I need stack
checking, I’ll put in my own, thank you!
I don’t want to allocate buffers from the pool for several
reasons. First, this is a portable driver and I want to keep
that part of it OS-independent, which means, no Windows-unique
code here. Second, I’m indeed performance critical, and this is
not quite the right place to waste time invoking OS APIs and
library functions that I do not know how they behave and how
much overhead they put in. Third, this code is very much used by
multiple boards and multiple chips, so, I have all the interest
to make it as short and sweet as I can, and as free from
side-effects as possible, and that includes making sure that
there’s few, or better, no calls to anything I didn’t write
myself or that I don’t control its source code.
The on-stack solution looks simple enough: just declare it as a
local array, and use it! The code is written in C and not in
C++, I inherited the driver, so, it takes a small but real
amount of code to do that kind of allocation even though I’d
rather be overriding my “new” operator and forgetting about
memory allocation issues altogether.
Alberto.
----- Original Message -----
From: “Peter Wieland”
To: “Windows System Software Devs Interest List”
Sent: Friday, September 16, 2005 3:22 AM
Subject: RE: Re:[ntdev] Access to parallel ports from Win32
Why would the linker magically generate code to fill in a
function
that’s not defined in the runtime library? Would you be happy
about
such code or would you be calling that a bug too?
Are you worried about the performance lost by a single function
call
being injected? Or are you explaining why you don’t want to
allocate
the buffers from pool? I can’t actually tell (perhaps it’s just
too
late)
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alberto
Moreira
Sent: Thursday, September 15, 2005 7:01 PM
To: Windows System Software Devs Interest List
Subject: Re: Re:[ntdev] Access to parallel ports from Win32
You know, I don’t know if I like the idea of the compiler
inserting
calls into my object code and the linker not filling them up.
Because
this is a checked build, I’m not sure I care about what kind of
code
they generate for me, as long as it works! But I believe that
if the
compiler includes a call to chkstk, the linker should fill it
up; and
I’m using the DDK compiler, mind you. So, to me at least this
looks like
a bug.
Anyway, I’ll use the pragma, because I can do that without
messing up
with batch and make files: I hate to do that kind of thing. This
buffer
is a staging area for setting up a stream of graphics rendering
commands
to my chip, and that stream can be rather longish; the
alternative is to
put it in the nonpaged pool, but why waste time allocating and
deallocating memory if I can do it otherwise ? Another
consideration is,
this is portable code, it must run just the same under Windows,
Linux
and Solaris, so, I can’t be too particular about API issues or I
end up
multiplying by three the number of lines of code I have to
write.
The other thing is, this is a very high performance environment,
which
uses a huge amount of memory, so, it can be quite tricky to
allocate and
use resources without bringing the whole machine to its knees!
The
driver is very carefully tuned to extract the maximum throughput
from
the chip and from the bus, and that’s the major consideration
here.
Trading performance for safety may not be a feasible strategy in
my
case! So, even if the checked build doesn’t like it, if it works
in the
production free build I’m happy with it. But meanwhile I have a
daily
build to satisfy and a QA manager that will be on my back in no
time if
I systematically break that build!
Alberto.
----- Original Message -----
From: “David J. Craig”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Thursday, September 15, 2005 12:13 PM
Subject: Re:[ntdev] Access to parallel ports from Win32
>A couple of people provided advice to suppress this behavior,
>but I disagree. Any local stack usage should be carefully
>examined and anything large should be a pointer on the stack
>that is allocated from either the paged or nonpaged pool. Try
>driver prefast and it will flag all allocations larger than 1KB
>and the utility permits this to be varied so it will report
>even smaller stack usage by a single function. I think
>anything about 256 bytes in a single function is probably
>excessive and a potential danger.
>
> You can’t use the __chkstk() function in drivers since it is
> not aware of the rules. It could be replaced by your own
> function that uses the correct stack limits and usage calls,
> but I prefer to just not cause a problem. Of course, this
> becomes far more critical in file system filters.
>
> “Alberto Moreira” wrote in message
> news:xxxxx@ntdev…
>> Hi, Guys,
>>
>> I’m having an annoying problem that’s simple enough that I
>> feel I should know the answer, yet it’s buried within the
>> structure of the Microsoft DDK toolset that I’m reluctant to
>> dig into. So I wonder if someone has some wisdom to share
>> with me ?
>>
>> The problem is this, whenever I have a structure on the stack
>> that’s larger than a certain size, the C compiler generates a
>> call to__chkstk() in my checked builds. That reference, for
>> this or that reason, is not satisfied by the linker. I want
>> to either suppress the generation of that code or to find
>> which library that function is defined; I’d prefer that the
>> compiler doesn’t generate that call to begin with.
>>
>> Do any of you know how to do it ? Tks,
>>
>>
>> Alberto.
>>
>>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ieee.org
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com
To unsubscribe send a blank email to
xxxxx@lists.osr.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to
xxxxx@lists.osr.com