From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Philippe Gerum <rpm@xenomai.org>
Cc: xenomai-help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] native: A 32k stack is not always a 'reasonable' size
Date: Thu, 08 Jul 2010 13:47:59 +0200 [thread overview]
Message-ID: <4C35BAEF.5020308@domain.hid> (raw)
In-Reply-To: <1278584354.1810.137.camel@domain.hid>
Philippe Gerum wrote:
> If I understand the glibc code properly, the stack cache is not
> pre-filled, but merely serves to recycle old stacks from terminated
> stacks. So, at least until a stack area could actually be reused from
> that cache, fresh new stack space for new threads is always obtained via
> mmap(), which means that we may have non-contiguous stack spaces most of
> the time. It seems that things would start to hit the crapper when some
> recycling takes place, in which case an overflow situation could cause a
> stack to overflow on its neighbor.
I am not sure I understand what you mean. So, I am going to try and show
you what I mean. I run the following program:
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void *thread(void *cookie)
{
int x;
printf("sp: %p\n", &x);
pause();
return cookie;
}
int main(void)
{
pthread_t ida, idb;
pthread_create(&ida, NULL, thread, NULL);
pthread_create(&idb, NULL, thread, NULL);
pthread_join(ida, NULL);
return 0;
}
On an ARMv7 (no FCSE involved) platform. It prints:
sp: 0x411a2ddc
sp: 0x409a2ddc
I then dump the process mappings, and I get everything contiguous:
401a4000-401a5000 ---p 00000000 00:00 0
401a5000-409a4000 rw-p 00000000 00:00 0
409a4000-409a5000 ---p 00000000 00:00 0
409a5000-411a4000 rw-p 00000000 00:00 0
So, it looks to me like if the thread with the highest stack address go
past below the guard page limit, it will overrun the other thread's stack.
On x86, this is a different story. I guess because the kernel or glibc
has a stack top randomization strategy.
--
Gilles.
next prev parent reply other threads:[~2010-07-08 11:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-06 19:25 [Xenomai-help] native: A 32k stack is not always a 'reasonable' size Peter Soetens
2010-07-07 9:06 ` Gilles Chanteperdrix
2010-07-07 20:57 ` Peter Soetens
2010-07-07 21:19 ` Gilles Chanteperdrix
2010-07-07 22:31 ` Peter Soetens
2010-07-07 23:08 ` Gilles Chanteperdrix
2010-07-08 8:37 ` Philippe Gerum
2010-07-08 8:58 ` Gilles Chanteperdrix
2010-07-08 9:31 ` Philippe Gerum
2010-07-08 9:35 ` Gilles Chanteperdrix
2010-07-08 9:58 ` Philippe Gerum
2010-07-08 10:04 ` Gilles Chanteperdrix
2010-07-08 10:09 ` Gilles Chanteperdrix
2010-07-08 11:52 ` Gilles Chanteperdrix
2010-07-08 9:50 ` Philippe Gerum
2010-07-08 9:55 ` Gilles Chanteperdrix
2010-07-08 10:19 ` Philippe Gerum
2010-07-08 11:47 ` Gilles Chanteperdrix [this message]
2010-07-08 15:01 ` Philippe Gerum
2010-07-08 16:33 ` Gilles Chanteperdrix
2010-07-11 13:15 ` Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C35BAEF.5020308@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=rpm@xenomai.org \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.