diff options
Diffstat (limited to 'src/libthread')
-rw-r--r-- | src/libthread/channel.c | 1 | ||||
-rw-r--r-- | src/libthread/daemonize.c | 4 | ||||
-rw-r--r-- | src/libthread/thread.c | 20 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/libthread/channel.c b/src/libthread/channel.c index 4dc51fcf..903889a4 100644 --- a/src/libthread/channel.c +++ b/src/libthread/channel.c @@ -249,6 +249,7 @@ chanalt(Alt *a) Channel *c; _Thread *t; + needstack(512); for(i=0; a[i].op != CHANEND && a[i].op != CHANNOBLK; i++) ; n = i; diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c index c6e00d19..4ed252e0 100644 --- a/src/libthread/daemonize.c +++ b/src/libthread/daemonize.c @@ -42,10 +42,12 @@ child(void) fprint(2, "%s: wait pid %d stopped\n", argv0, pid); return; } +#ifdef WIFCONTINUED if(WIFCONTINUED(status)){ fprint(2, "%s: wait pid %d continued\n", argv0, pid); return; } +#endif fprint(2, "%s: wait pid %d status 0x%ux\n", argv0, pid, status); _exit(99); } @@ -84,8 +86,6 @@ _threadsetupdaemonize(void) sigpid = 1; - threadlinklibrary(); - if(pipe(p) < 0) sysfatal("passer pipe: %r"); diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 2b6d1e37..b886e30b 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -169,6 +169,7 @@ _threadswitch(void) { Proc *p; + needstack(0); p = proc(); //print("threadswtch %p\n", p); contextswitch(&p->thread->context, &p->schedcontext); @@ -324,6 +325,20 @@ threadsetstate(char *fmt, ...) va_end(arg); } +void +needstack(int n) +{ + _Thread *t; + + t = proc()->thread; + + if((char*)&t <= (char*)t->stk + || (char*)&t - (char*)t->stk < 256+n){ + fprint(2, "thread stack overflow\n"); + abort(); + } +} + /* * locking */ @@ -499,11 +514,6 @@ threadmainstart(void *v) threadmain(threadargc, threadargv); } -void -threadlinklibrary(void) -{ -} - int main(int argc, char **argv) { |