[Python-Dev] stack check on Unix: any suggestions? (original) (raw)

Thomas Wouters thomas@xs4all.net
Tue, 29 Aug 2000 22:31:08 +0200


On Tue, Aug 29, 2000 at 03:12:57PM -0500, Skip Montanaro wrote:

On most (all?) processors in common usage, the stack grows down toward the heap and the heap brows upward, so what you really want to do is detect that collision. brk and sbrk are used to manipulate the end of the heap. A local variable in the current scope should be able to tell you roughly where the top of stack is.

I don't think that'll help, because the limit isn't the actual (physical) memory limit, but mostly just administrative limits. 'limit' or 'limits', depending on your shell.

current top of stack. If obmalloc brks() memory back to the system (I've never looked at it - I'm just guessing) it could lower the saved value to the last address in the block below the just recycled block.

Last I looked, obmalloc() worked on top of the normal system malloc (or its replacement if you provide one) and doesn't brk/sbrk itself (thank god -- that would mean nastiness if extention modules or such used malloc, or if python were embedded into a system using malloc!)

-- Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!