M gnot/trap.c => gnot/trap.c +8 -0
@@ 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;
M pc/trap.c => pc/trap.c +9 -3
@@ 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);
M port/chan.c => port/chan.c +14 -1
@@ 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;
}
M power/trap.c => power/trap.c +1 -0
@@ 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);
M ss/trap.c => ss/trap.c +8 -0
@@ 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;