diff options
author | Robert Morris <[email protected]> | 2019-07-23 12:17:17 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2019-07-23 12:17:17 -0400 |
commit | 54178ad94d758e557bfa369b7f137e2844e030e1 (patch) | |
tree | cc2446a7d55d35e30f12f26e44aef68d285bfc91 /user | |
parent | 55bc96d4190e40704fb5e447cef9597b08b8f088 (diff) | |
download | xv6-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.c | 10 |
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 |