kill user process when it generates an unhandled trap (e.g., 13)

fix bug in test code of malloc
This commit is contained in:
kaashoek 2006-08-25 00:43:17 +00:00
parent 81d5219998
commit 74493bf446
3 changed files with 3 additions and 19 deletions

4
trap.c
View file

@ -126,8 +126,10 @@ trap(struct trapframe *tf)
}
cprintf("trap %d from cpu %d eip %x\n", v, cpu(), tf->eip);
if(curproc[cpu()])
if(curproc[cpu()]) {
cprintf("pid %d\n", curproc[cpu()]->pid);
proc_exit();
}
// panic("trap");
return;

View file

@ -26,8 +26,6 @@ free(void *ap)
{
Header *bp, *p;
printf(1, "free\n");
bp = (Header *) ap - 1;
for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if (p >= p->s.ptr && (bp > p || bp < p->s.ptr))
@ -53,7 +51,6 @@ morecore(uint nu)
if (nu < PAGE)
nu = PAGE;
printf(1, "call sbrk\n");
cp = sbrk(nu * sizeof(Header));
if (cp == (char *) -1)
return 0;
@ -69,8 +66,6 @@ malloc(uint nbytes)
Header *p, *prevp;
uint nunits;
printf(1, "malloc %d\n", nbytes);
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if ((prevp = freep) == 0) {
base.s.ptr = freep = prevp = &base;
@ -86,7 +81,6 @@ malloc(uint nbytes)
p->s.size = nunits;
}
freep = prevp;
printf(1, "malloc returns: %d\n", (int) (p+1));
return (void *) (p + 1);
}
if (p == freep)

View file

@ -120,20 +120,8 @@ exitwait(void)
void
mem(void)
{
void *m = malloc(4096);
void *m1, *m2;
free(m + 3*1024);
free(m + 2*1024);
free(m + 1024);
free(m);
m1 = malloc(4096);
if (m1 != m) {
puts("didn't coalesce\n");
exit();
}
free(m1);
m1 = 0;
while ((m2 = malloc(1024)) != 0) {
*(char **) m2 = m1;