[uClinux-dev] brk(2) and stack pointer
Shaun Jackman
sjackman@gmail.com
Fri Apr 28 19:51:00 GMT 2006
On 4/28/06, Jamie Lokier <jamie@shareable.org> wrote:
> A few programs allocate memory on the heap, and then use that as a
> stack (possibly one of several stacks). Programs which do that will
> fail your test, unless malloc(3) is implemented by doing anonymous
> mmap(2) instead of brk(2).
>
> Such programs tend to be those doing user-space threading or clever
> things with signals. Those techniques are relatively portable and
> valid, using "sigaltstack" or "makecontext", so although most programs
> don't use them, a few do that you might want to use (or someone else
> using newlib on ARM might want to use).
Thanks for the explanation.
> What's the reason for the check?
For the typical case where the heap is growing up towards the stack,
which is growing down, I wanted to check that the requested heap
hasn't collided with the stack.
Cheers,
Shaun
More information about the Newlib
mailing list