Skip to content

Commit

Permalink
kill user process when it generates an unhandled trap (e.g., 13)
Browse files Browse the repository at this point in the history
fix bug in test code of malloc
  • Loading branch information
kaashoek committed Aug 25, 2006
1 parent 81d5219 commit 74493bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
4 changes: 3 additions & 1 deletion trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions umalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions usertests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 74493bf

Please sign in to comment.