Fixes exec-bound-3 failures
[pintos-anon] / src / tests / userprog / exec-bound-3.c
1 /* Invokes an exec system call with the exec string straddling a
2    page boundary such that the first byte of the string is valid
3    but the remainder of the string is in invalid memory. Must
4    kill process. */
5
6 #include <syscall-nr.h>
7 #include "tests/userprog/boundary.h"
8 #include "tests/lib.h"
9 #include "tests/main.h"
10
11 void
12 test_main (void) 
13 {
14   char *p = get_bad_boundary () - 1;
15   *p = 'a';
16   exec(p);
17
18   /* Note: if this test fails to pass even with the official solutions,
19      it's probably because memory layout has changed and p no longer
20      refers to the proper page boundary. To fix the problem, uncomment
21      the line below to print out the boundary address. In addition,
22      add a printf line in load_segment to print out the address range
23      of each segment. From that, you'll be able to figure out how to
24      modify get_bad_boundary to make things work again. */
25
26   // msg("boundary address: 0x%x", p);
27   fail ("should have killed process");
28 }