From fb852844d2172fba9690b36b89d97c671ec52978 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 22 Jul 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-07-22 --- gnot/trap.c | 8 ++++++++ pc/trap.c | 12 +++++++++--- port/chan.c | 15 ++++++++++++++- power/trap.c | 1 + ss/trap.c | 8 ++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gnot/trap.c b/gnot/trap.c index a48ba88e884cdce08ead648c1f5b943033aa922e..1bf8261228a1ec06a513479ec137f5ff1f379efd 100644 --- a/gnot/trap.c +++ b/gnot/trap.c @@ -162,6 +162,14 @@ notify(Ureg *ur) u->svsr = ur->sr; sp = ur->usp; sp -= sizeof(Ureg); + if(waserror()){ + pprint("suicide: trap in notify\n"); + unlock(&u->p->debug); + pexit("Suicide", 0); + } + validaddr((ulong)u->notify, 1, 0); + validaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0); + poperror(); u->ureg = (void*)sp; memmove((Ureg*)sp, ur, sizeof(Ureg)); sp -= ERRLEN; diff --git a/pc/trap.c b/pc/trap.c index 563045fd4b41467cb589a10af0070ba0fc2189a5..0a6300ae762b2eb9f827b1af52ab797778eb9f86 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -303,6 +303,14 @@ notify(Ureg *ur) u->svflags = ur->flags; sp = ur->usp; sp -= sizeof(Ureg); + if(waserror()){ + pprint("suicide: trap in notify\n"); + unlock(&u->p->debug); + pexit("Suicide", 0); + } + validaddr((ulong)u->notify, 1, 0); + validaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0); + poperror(); u->ureg = (void*)sp; memmove((Ureg*)sp, ur, sizeof(Ureg)); sp -= ERRLEN; @@ -351,9 +359,7 @@ noted(Ureg *ur, ulong arg0) case NCONT: splhi(); unlock(&u->p->debug); - rfnote(ur); - break; - /* never returns */ + return; default: pprint("unknown noted arg 0x%lux\n", arg0); diff --git a/port/chan.c b/port/chan.c index d6994fa45fa99295505554d87318cc9bf47b1ab3..94432d96a639732de299402d5f0c84cc64d29d78 100644 --- a/port/chan.c +++ b/port/chan.c @@ -22,16 +22,29 @@ incref(Ref *r) return x; } +#include "ureg.h" + int decref(Ref *r) { int x; + int i; + Segment *s; lock(r); x = --r->ref; unlock(r); - if(x < 0) + if(x < 0) { + if(u) { + print("%d: %s %lux %lux\n", u->p->pid, u->p->text, *(ulong*)((Ureg*)UREGADDR)->pc, r); + for(i = 0; i < NSEG; i++) { + s = u->p->seg[i]; + if(s) + print("%d: %lux %lux %lux", i, s, s->base, s->top); + } + } panic("decref"); + } return x; } diff --git a/power/trap.c b/power/trap.c index b5ae91d6f027d1eaca4d20a1e9a714b5b6759c56..ee6858195e2bb8b8cf5232c01f7b7a4dd5f46393 100644 --- a/power/trap.c +++ b/power/trap.c @@ -392,6 +392,7 @@ notify(Ureg *ur) sp -= sizeof(Ureg); if(waserror()){ pprint("suicide: trap in notify\n"); + unlock(&u->p->debug); pexit("Suicide", 0); } validaddr((ulong)u->notify, 1, 0); diff --git a/ss/trap.c b/ss/trap.c index 846d4708b05406da5fda29c16925a4a53352e4f5..6c1963f336c38a2fce18eb692bd8d1fec9faead8 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -235,6 +235,14 @@ notify(Ureg *ur) u->svpsr = ur->psr; sp = ur->usp; sp -= sizeof(Ureg); + if(waserror()){ + pprint("suicide: trap in notify\n"); + unlock(&u->p->debug); + pexit("Suicide", 0); + } + validaddr((ulong)u->notify, 1, 0); + validaddr(sp-ERRLEN-3*BY2WD, sizeof(Ureg)+ERRLEN-3*BY2WD, 0); + poperror(); u->ureg = (void*)sp; memmove((Ureg*)sp, ur, sizeof(Ureg)); sp -= ERRLEN;