Manual Reference Pages - NEEDSTACK (3)
needstack - check for execution stack overflow
int needstack(int n)
Stack overflow in the thread library leads to bugs that are
difficult to diagnose.
The Plan 9 libraries are careful about not allocating
large structures on the stack, so typically four or eight kilobytes is plenty of stack
for a thread.
Other libraries are not always as careful.
needstack indicates to the thread library that an external routine is about
to be called that will require
n bytes of stack space.
If there is not enough space left on the stack,
the thread library prints an error and terminates
needstack(0) can be used to check whether the stack is
Needstack is defined in
libc.h so that library functions used in threaded and non-threaded contexts
can call it.
The implementation of
lib9 is a no-op.
Needstack should be thought of as a comment checked at run time,
The X Window library implementation of
XLookupString allocates some very large buffers on the stack, so
needstack(20*1024) before making calls to
XLookupString. If a thread (in this case, the keyboard-reading thread used
does not allocate a large enough stack, the problem is diagnosed
immediately rather than left to corrupt memory.
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.