diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 51fdac8..eb17a4d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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", } diff --git a/hake/menu.lst.armv8_a57_qemu b/hake/menu.lst.armv8_a57_qemu index 033c294..67267cd 100644 --- a/hake/menu.lst.armv8_a57_qemu +++ b/hake/menu.lst.armv8_a57_qemu @@ -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... diff --git a/hake/menu.lst.armv8_imx8x b/hake/menu.lst.armv8_imx8x index 68a2824..7b1c237 100644 --- a/hake/menu.lst.armv8_imx8x +++ b/hake/menu.lst.armv8_imx8x @@ -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 diff --git a/include/test_stackoverflow.h b/include/test_stackoverflow.h new file mode 100644 index 0000000..dcb6c3c --- /dev/null +++ b/include/test_stackoverflow.h @@ -0,0 +1,8 @@ +#ifndef __TEST_STACKOVERFLOW_H +#define __TEST_STACKOVERFLOW_H + +#include + +void do_test_stackoverflow(void); + +#endif /* __TEST_STACKOVERFLOW_H */ \ No newline at end of file diff --git a/lib/aos/threads.c b/lib/aos/threads.c index eeea8e7..d730fab 100644 --- a/lib/aos/threads.c +++ b/lib/aos/threads.c @@ -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; diff --git a/lib/grading/Hakefile b/lib/grading/Hakefile index 658dd91..96e668f 100644 --- a/lib/grading/Hakefile +++ b/lib/grading/Hakefile @@ -21,7 +21,8 @@ "test_paging.c", "test_spawn.c", "test_ipc.c", - "test_threads.c" + "test_threads.c", + "test_stackoverflow.c" ], addLibraries = [ ] diff --git a/lib/grading/grading.c b/lib/grading/grading.c index 4599a0b..b35ad3c 100644 --- a/lib/grading/grading.c +++ b/lib/grading/grading.c @@ -14,6 +14,7 @@ #include #include #include +#include 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 diff --git a/lib/grading/test_stackoverflow.c b/lib/grading/test_stackoverflow.c new file mode 100644 index 0000000..7143bab --- /dev/null +++ b/lib/grading/test_stackoverflow.c @@ -0,0 +1,17 @@ +#include +#include +#include + +#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]))); + } +} diff --git a/platforms/Hakefile b/platforms/Hakefile index 9b52478..9df7578 100644 --- a/platforms/Hakefile +++ b/platforms/Hakefile @@ -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 [ diff --git a/usr/stackoverflow/Hakefile b/usr/stackoverflow/Hakefile new file mode 100644 index 0000000..f34b5c9 --- /dev/null +++ b/usr/stackoverflow/Hakefile @@ -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" ] + } +] diff --git a/usr/stackoverflow/main.c b/usr/stackoverflow/main.c new file mode 100644 index 0000000..08c57ca --- /dev/null +++ b/usr/stackoverflow/main.c @@ -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 +#include + +#include + +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); +} \ No newline at end of file