stack space mapping question

Robert Stroud robert at cheviot.UUCP
Wed Feb 6 04:09:18 AEST 1985


In article <21131 at arizona.UUCP> whm at arizona.UUCP (Bill Mitchell) asks
whether stack pages grabbed while the stack is deep are ever reclaimed
by the system when the stack recedes.

>                   On 4.2 on Suns and Vaxes, the system does allow (based
>on empirical studies rather than code examination) access to pages below
>the sp as long as they were properly contained in the stack at some point
>in time.  Is this implementation dependent or is this some sort of standard
>Unix "feature"?
>
>					Thanks in advance,
>					Bill Mitchell
>					whm.arizona at csnet-relay
>					{ihnp4,noao,mcnc,utah-cs}!arizona!whm


I don't know about more recent versions of Unix, but this was a "feature"
of the PDP-11 V7 implementation where I first met Unix. I used it to extend
my data area beyond 56K without fear of a segmentation violation.

The memory mapping hardware on this PDP-11 restricted you to 8 segments, each
of which could address up to 8K in steps of 64 bytes - or something like that.
Because Unix must always have a stack segment, you couldn't extend your memory
(using sbrk) beyond 56K (or 8 - 1 segments).

However, if you extended the stack segment to its full 8K by setting,
de-referencing and then re-setting the stack pointer, and set your break
to 56K, then the full 64K address space was addressable without any
danger of segmentation violation, and you could sneak a few extra bytes
into the bottom of the stack segment from the top of the data segment.

The danger with this is that you lose the memory protection facilities
and stack overflow checks, but as far as I could tell, the memory was
never reclaimed. Obviously, a more modern Unix uses much more sophisticated
memory management hardware, so this part of the kernel code has probably
been completely rewritten. On the other hand, if it was in V7....

I wasn't particularly proud of this trick, but it got me out of a hole.
If anyone else out there is still using PDP-11's(!), they may find it useful.

Robert Stroud,
Computing Laboratory,
University of Newcastle upon Tyne.

ARPA robert%cheviot%newcastle.mailnet at mit-multics.arpa
UUCP ...!ukc!cheviot!robert

"Unix is what runs on Dennis Ritchie's machine!"



More information about the Comp.unix.wizards mailing list