Re: Stack among threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 09 September 2006 21:06, Mauricio Lin wrote:
>
> Humm, now the maps output is clear in terms of stacks for a
> multithreaded application. If other threads stack are dynamically
> allocated, are the size of these stacks computed or counted as the size
> of application heap area?
>

While the stacks could very well be allocated from the heap*, the Linux 
implementation is a bit more clever. 

It creates 2 mmap() segments, one with the length of the page size with no 
access rights, and one right above the first segment with read/write access. 
The later will actually be used as the stack. With this setup, a stack 
overflow will generate a SIGSEGV, which is much better then silently 
overwritting other data.

*The strict definition of the heap is the memory segment which is adjusted by 
brk(). In /proc/pid/maps it is marked with [heap].

tavi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux