summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-07-23 12:17:17 -0400
committerRobert Morris <[email protected]>2019-07-23 12:17:17 -0400
commit54178ad94d758e557bfa369b7f137e2844e030e1 (patch)
treecc2446a7d55d35e30f12f26e44aef68d285bfc91 /user
parent55bc96d4190e40704fb5e447cef9597b08b8f088 (diff)
downloadxv6-labs-54178ad94d758e557bfa369b7f137e2844e030e1.tar.gz
xv6-labs-54178ad94d758e557bfa369b7f137e2844e030e1.tar.bz2
xv6-labs-54178ad94d758e557bfa369b7f137e2844e030e1.zip
simplify kernel mapping calls
Diffstat (limited to 'user')
-rw-r--r--user/usertests.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/user/usertests.c b/user/usertests.c
index 98a5838..42065f4 100644
--- a/user/usertests.c
+++ b/user/usertests.c
@@ -1884,26 +1884,30 @@ rand()
return randstate;
}
+// check that there's an invalid page beneath
+// the user stack, to catch stack overflow.
void
stacktest()
{
int pid;
+ int ppid = getpid();
- printf(1, "stack test\n");
+ printf(1, "stack guard test\n");
pid = fork();
if(pid == 0) {
char *sp = (char *) r_sp();
- printf(1, "%p\n", sp);
sp -= 4096;
+ // the *sp should cause a trap.
printf(1, "stacktest: read below stack %p\n", *sp);
printf(1, "stacktest: test FAILED\n");
+ kill(ppid);
exit();
} else if(pid < 0){
printf (1, "fork failed\n");
exit();
}
wait();
- printf(1, "stack test done\n");
+ printf(1, "stack guard test ok\n");
}
int