On Thu, Jun 19, 2003 at 04:49:38PM +0300, Nadav Har'El wrote:
> On Thu, Jun 19, 2003, Orna Agmon wrote about "Re: [Haifux] stack size":
> > Eli, I am not trying to prove a point, but find something automatic that
> > will tell me when the struct is too large, and I should use the heap. I
>
> Ok, here's an automatic algorithm for you: for each structure you have
> defined in your program and initialized as an automatic variable, add code:
>
> if(sizeof(thestruct) > 1000){
> fprintf(stderr,"thestruct is a very big struct!\n");
> }
>
> (exercise: do this automatically using a Perl script, or whatever).A much better way is mentioned here: http://bugzilla.kernel.org/show_bug.cgi?id=386 Basically, you disassemble the .o files and look for instructions of the form 'sub CONSTANT, %esp', where constant is bigger than a threshold. We use 0x100 in the kernel (256bytes), anything bigger is a bad idea. A script to do this is at http://kernelnewbies.org/scripts/check-stack.sh -- Muli Ben-Yehuda http://www.mulix.org http://www.livejournal.com/~mulix/
pgp00000.pgp
Description: PGP signature
