This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [uClinux-dev] brk(2) and stack pointer


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]