aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2020-01-24 13:09:55 -0500
committerRuss Cox <rsc@swtch.com>2020-01-24 13:09:55 -0500
commit4197af4122bc06cf4062ca2d1d5bc8f973e37cf1 (patch)
tree19601cab718aed75d2d0b9808a0d3241534980a0 /src
parent93e2e820a5551ba3d0a1e0f0fbd4c5eb65e18ce6 (diff)
downloadplan9port-4197af4122bc06cf4062ca2d1d5bc8f973e37cf1.tar.gz
plan9port-4197af4122bc06cf4062ca2d1d5bc8f973e37cf1.tar.bz2
plan9port-4197af4122bc06cf4062ca2d1d5bc8f973e37cf1.zip
libthread: comment stack border a bit more
Diffstat (limited to 'src')
-rw-r--r--src/libthread/thread.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libthread/thread.c b/src/libthread/thread.c
index 2e654863..f657b5b2 100644
--- a/src/libthread/thread.c
+++ b/src/libthread/thread.c
@@ -136,10 +136,16 @@ threadalloc(void (*fn)(void*), void *arg, uint stack)
sysfatal("threadalloc getcontext: %r");
//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn);
- /* call makecontext to do the real work. */
- /* leave a few words open on both ends */
- t->context.uc.uc_stack.ss_sp = (void*)(t->stk+8);
- t->context.uc.uc_stack.ss_size = t->stksize-64;
+ /*
+ * Call makecontext to do the real work.
+ * To avoid various mistakes on other system software,
+ * debuggers, and so on, don't get too close to both
+ * ends of the stack. Just staying away is much easier
+ * than debugging everything (outside our control)
+ * that has off-by-one errors.
+ */
+ t->context.uc.uc_stack.ss_sp = (void*)(t->stk+64);
+ t->context.uc.uc_stack.ss_size = t->stksize-2*64;
#if defined(__sun__) && !defined(__MAKECONTEXT_V2_SOURCE) /* sigh */
/* can avoid this with __MAKECONTEXT_V2_SOURCE but only on SunOS 5.9 */
t->context.uc.uc_stack.ss_sp =