mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Kernel Stack Limit...
@ 2002-08-29 19:07 Raj, Ashok
  2002-08-29 19:15 ` Robert Love
  2002-08-29 19:28 ` Richard B. Johnson
  0 siblings, 2 replies; 4+ messages in thread
From: Raj, Ashok @ 2002-08-29 19:07 UTC (permalink / raw)
  To: Linux-Kernel (E-mail)

Hello.

Please reply to me, since i dont have this email id on the list. 

Could someone tell me at what the kernel stack size limit is? 

Is there a gcc option for x86 that can warn if too large variables are
specified in the stack?

recently we had a problem with one variable accidently declared on the stack
which was quite large, and when
some calls nested, we noticed stack corruption. Once the variable was moved
to global, the corruption went away. We would always see that some member of

"current" would be corrupted, so when the user mode program exits, we will
notice the files member would be having garbage values.

if there is a compiler option to force that during compilation to point out
such weirdness, or if a runtime check could be done during each function
exit, 
it would be really useful.

thanks
ashokr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Kernel Stack Limit...
  2002-08-29 19:07 Kernel Stack Limit Raj, Ashok
@ 2002-08-29 19:15 ` Robert Love
  2002-08-29 19:18   ` Randy.Dunlap
  2002-08-29 19:28 ` Richard B. Johnson
  1 sibling, 1 reply; 4+ messages in thread
From: Robert Love @ 2002-08-29 19:15 UTC (permalink / raw)
  To: Raj, Ashok; +Cc: Linux-Kernel (E-mail)

On Thu, 2002-08-29 at 15:07, Raj, Ashok wrote:

> Please reply to me, since i dont have this email id on the list. 
> 
> Could someone tell me at what the kernel stack size limit is? 

It depends on the architecture.  8KB for x86 and most others.  Some
(all?) 64-bit platforms have 16KB stacks.

Note the effective size is actually (8KB - sizeof(task_struct)) in 2.4
and (8KB - sizeof(thread_info)) in 2.5 since those structures are stored
at the top of the stack.

Also note interrupts share the stack.

> Is there a gcc option for x86 that can warn if too large variables are
> specified in the stack?

I believe 2.4-ac has a stack overflow check in it... as does the RedHat
kernel - check it out.

Also kgdb (or at least our copy here at MontaVista) has a stack overflow
check.

	Robert Love


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Kernel Stack Limit...
  2002-08-29 19:15 ` Robert Love
@ 2002-08-29 19:18   ` Randy.Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy.Dunlap @ 2002-08-29 19:18 UTC (permalink / raw)
  To: Robert Love; +Cc: Raj, Ashok, Linux-Kernel (E-mail)

On 29 Aug 2002, Robert Love wrote:

| On Thu, 2002-08-29 at 15:07, Raj, Ashok wrote:
|
| > Please reply to me, since i dont have this email id on the list.
| >
| > Could someone tell me at what the kernel stack size limit is?
|
| It depends on the architecture.  8KB for x86 and most others.  Some
| (all?) 64-bit platforms have 16KB stacks.
|
| Note the effective size is actually (8KB - sizeof(task_struct)) in 2.4
| and (8KB - sizeof(thread_info)) in 2.5 since those structures are stored
| at the top of the stack.
|
| Also note interrupts share the stack.
|
| > Is there a gcc option for x86 that can warn if too large variables are
| > specified in the stack?
|
| I believe 2.4-ac has a stack overflow check in it... as does the RedHat
| kernel - check it out.
|
| Also kgdb (or at least our copy here at MontaVista) has a stack overflow
| check.

Also Keith Owens posted a script in the last couple of days
that checks stack depth.

-- 
~Randy



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Kernel Stack Limit...
  2002-08-29 19:07 Kernel Stack Limit Raj, Ashok
  2002-08-29 19:15 ` Robert Love
@ 2002-08-29 19:28 ` Richard B. Johnson
  1 sibling, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2002-08-29 19:28 UTC (permalink / raw)
  To: Raj, Ashok; +Cc: Linux-Kernel (E-mail)

On Thu, 29 Aug 2002, Raj, Ashok wrote:

> Hello.
> 
> Please reply to me, since i dont have this email id on the list. 
> 
> Could someone tell me at what the kernel stack size limit is? 
> 

Only two PAGES, 0x1000 per page on a ix86.

> Is there a gcc option for x86 that can warn if too large variables are
> specified in the stack?
> 

sizeof(whatever_local_variable)

> recently we had a problem with one variable accidently declared on the stack
> which was quite large, and when
> some calls nested, we noticed stack corruption. Once the variable was moved
> to global, the corruption went away. We would always see that some member of
>

Yes strange things happen when stack, which goes down, meets data...


Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
The US military has given us many words, FUBAR, SNAFU, now ENRON.
Yes, top management were graduates of West Point and Annapolis.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-29 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-29 19:07 Kernel Stack Limit Raj, Ashok
2002-08-29 19:15 ` Robert Love
2002-08-29 19:18   ` Randy.Dunlap
2002-08-29 19:28 ` Richard B. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®