user/usertests.c
void
stacktest()
{
  int pid;
  int ppid = getpid();
  
  printf("stack guard test\n");
  pid = fork();
  if(pid == 0) {
    char *sp = (char *) r_sp();
    sp -= PGSIZE;
    // the *sp should cause a trap.
    printf("stacktest: read below stack %p\n", *sp);
    printf("stacktest: test FAILED\n");
    kill(ppid);
    exit(1);
  } else if(pid < 0){
    printf("fork failed\n");
    exit(1);
  }
  wait(0);
  printf("stack guard test ok\n");
}
// check that there's an invalid page beneath
// the user stack, to catch stack overflow.
check that there's an invalid page beneath
the user stack, to catch stack overflow.
check that there ' s an invalid page beneath the user stack to catch stack overflow .
void
stacktest()
{
  int pid;
  int ppid = getpid();
  printf("stack guard test\n");
  pid = fork();
  if(pid == 0) {
    char *sp = (char *) r_sp();
    sp -= PGSIZE;
    printf("stacktest: read below stack %p\n", *sp);
    printf("stacktest: test FAILED\n");
    kill(ppid);
    exit(1);
  } else if(pid < 0){
    printf("fork failed\n");
    exit(1);
  }
  wait(0);
  printf("stack guard test ok\n");
}
void stacktest ( ) { int pid ; int ppid = getpid ( ) ; printf ( " \n " ) ; pid = fork ( ) ; if ( pid == 0 ) { char * sp = ( char * ) r_sp ( ) ; sp -= PGSIZE ; printf ( " \n " , * sp ) ; printf ( " \n " ) ; kill ( ppid ) ; exit ( 1 ) ; } else if ( pid < 0 ) { printf ( " \n " ) ; exit ( 1 ) ; } wait ( 0 ) ; printf ( " \n " ) ; }
check that there's an invalid page beneath
the user stack, to catch stack overflow.
check that there ' s an invalid page beneath the user stack to catch stack overflow .
// the *sp should cause a trap.