A tale of two C's.

Doug Gwyn gwyn at brl-smoke.ARPA
Wed Apr 27 03:19:08 AEST 1988


In article <195 at sdeggo.UUCP> dave at sdeggo.UUCP (David L. Smith) writes:
-Whether or not this was necessary I'm not sure, but it does seem 
-like the easiest way to implement it.  The stack is set at the top 
-of memory; when it grows to big it generates a segmentation violation 
-which causes malloc() to allocate more memory and relocate the stack 
-at the top of memory.  The other alternative, if implemented with 
-vanilla malloc, would be to give some memory to the stack and then 
-monitor it everytime something was put on the stack to make sure it 
-didn't overflow.  Relying on the system to tell you when you're
-out of space is a lot easier.

It also doesn't work right on some systems such as MC68000s.
Several of us spent a lot of time getting this fixed, and the BRL
version of the Bourne shell can be configured to take the tedious
but correct approach instead of relying on the SIGSEGV kludge.

I think it serves as a good illustration of what can go wrong with
preempting library routines rather than cooperating with them.



More information about the Comp.lang.c mailing list