add stackoverflow test
This commit is contained in:
parent
f6364278d0
commit
3c85b4d971
@ -19,7 +19,7 @@
|
||||
|
||||
// allow access to the toradex board
|
||||
"runArgs": ["--privileged"],
|
||||
"mounts": ["type=bind,src=/dev/bus/usb,dst=/dev/bus/usb"],
|
||||
// "mounts": ["type=bind,src=/dev/bus/usb,dst=/dev/bus/usb"],
|
||||
|
||||
"remoteUser": "vscode",
|
||||
}
|
||||
|
||||
@ -8,5 +8,6 @@ module /armv8/sbin/init
|
||||
module /armv8/sbin/hello spawn
|
||||
module /armv8/sbin/memeater
|
||||
module /armv8/sbin/mallocator
|
||||
module /armv8/sbin/stackoverflow
|
||||
|
||||
# End of file, this needs to have a certain length...
|
||||
|
||||
@ -8,3 +8,4 @@ module /armv8/sbin/init
|
||||
module /armv8/sbin/hello spawn
|
||||
module /armv8/sbin/memeater
|
||||
module /armv8/sbin/mallocator
|
||||
module /armv8/sbin/stackoverflow
|
||||
|
||||
8
include/test_stackoverflow.h
Normal file
8
include/test_stackoverflow.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __TEST_STACKOVERFLOW_H
|
||||
#define __TEST_STACKOVERFLOW_H
|
||||
|
||||
#include <aos/aos.h>
|
||||
|
||||
void do_test_stackoverflow(void);
|
||||
|
||||
#endif /* __TEST_STACKOVERFLOW_H */
|
||||
@ -345,6 +345,7 @@ struct thread *thread_create_unrunnable(thread_func_t start_func, void *arg,
|
||||
size_t stacksize)
|
||||
{
|
||||
// allocate stack
|
||||
// debug_printf("[thread_create_unrunnable] stacksize = %x\n", stacksize);
|
||||
assert((stacksize % sizeof(uintptr_t)) == 0);
|
||||
stacksize += BASE_PAGE_SIZE;
|
||||
size_t bytes_allocated;
|
||||
|
||||
@ -21,7 +21,8 @@
|
||||
"test_paging.c",
|
||||
"test_spawn.c",
|
||||
"test_ipc.c",
|
||||
"test_threads.c"
|
||||
"test_threads.c",
|
||||
"test_stackoverflow.c"
|
||||
],
|
||||
addLibraries = [
|
||||
]
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <test_spawn.h>
|
||||
#include <test_ipc.h>
|
||||
#include <test_threads.h>
|
||||
#include <test_stackoverflow.h>
|
||||
|
||||
void
|
||||
grading_setup_bsp_init(int argc, char **argv) {
|
||||
@ -40,6 +41,7 @@ grading_test_early(void) {
|
||||
// do_test_spawn();
|
||||
// do_test_ipc();
|
||||
do_test_threads();
|
||||
do_test_stackoverflow();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
17
lib/grading/test_stackoverflow.c
Normal file
17
lib/grading/test_stackoverflow.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <test_stackoverflow.h>
|
||||
#include <test_helper.h>
|
||||
#include <spawn/spawn.h>
|
||||
|
||||
#define PROCESS_COUNT 1
|
||||
|
||||
void do_test_stackoverflow(void) {
|
||||
debug_printf("[do_test_stackoverflow]\n");
|
||||
|
||||
struct spawninfo *si = malloc(PROCESS_COUNT * sizeof(struct spawninfo));
|
||||
domainid_t *pid = malloc(PROCESS_COUNT * sizeof(domainid_t));
|
||||
|
||||
for(uint i = 0; i < PROCESS_COUNT; ++i) {
|
||||
debug_printf("[do_test_stackoverflow]: spawn %u\n", i);
|
||||
CHECK_ERR(spawn_load_by_name("stackoverflow", &(si[i]), &(pid[i])));
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
let
|
||||
-- Default list of modules to build/install
|
||||
modules_common = [ "/sbin/" ++ f | f <- [ "init", "hello", "memeater", "mallocator"
|
||||
modules_common = [ "/sbin/" ++ f | f <- [ "init", "hello", "memeater", "mallocator", "stackoverflow"
|
||||
] ]
|
||||
in
|
||||
[
|
||||
|
||||
18
usr/stackoverflow/Hakefile
Normal file
18
usr/stackoverflow/Hakefile
Normal file
@ -0,0 +1,18 @@
|
||||
--------------------------------------------------------------------------
|
||||
-- Copyright (c) 2007-2010, ETH Zurich.
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- This file is distributed under the terms in the attached LICENSE file.
|
||||
-- If you do not find this file, copies can be found by writing to:
|
||||
-- ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
|
||||
--
|
||||
-- Hakefile for /usr/init
|
||||
--
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
[ build application
|
||||
{
|
||||
target = "stackoverflow",
|
||||
cFiles = [ "main.c" ]
|
||||
}
|
||||
]
|
||||
33
usr/stackoverflow/main.c
Normal file
33
usr/stackoverflow/main.c
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* \file
|
||||
* \brief that intentionally creates a stack overflow
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016, ETH Zurich.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is distributed under the terms in the attached LICENSE file.
|
||||
* If you do not find this file, copies can be found by writing to:
|
||||
* ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <aos/aos.h>
|
||||
|
||||
void stackoverflow(int i);
|
||||
|
||||
void stackoverflow(int i) {
|
||||
void * pointer = NULL;
|
||||
volatile char filler[BASE_PAGE_SIZE];
|
||||
filler[0] = 'a';
|
||||
debug_printf("i = %d, pointer = %p\n", i, &pointer);
|
||||
stackoverflow(i + 1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
stackoverflow(0);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user