From 9f690b8cf81a8eaafa43c30bf7e076b3be85f4c1 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Mon, 1 Jul 2002 21:14:20 +0000 Subject: [PATCH] Now fills the stack with 0xdeadbeef git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1290 a1c6a512-1295-4272-9138-f99709370657 --- firmware/thread.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/firmware/thread.c b/firmware/thread.c index fc8370b42d..d1cd8da6ef 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -99,10 +99,22 @@ void switch_thread(void) */ int create_thread(void* function, void* stack, int stack_size) { + unsigned int i; + unsigned int stacklen; + unsigned int *stackptr; + if (num_threads >= MAXTHREADS) return -1; else { + /* Munge the stack to make it easy to spot stack overflows */ + stacklen = stack_size / 4; + stackptr = stack; + for(i = 0;i < stacklen;i++) + { + stackptr[i] = 0xdeadbeef; + } + struct regs* regs = &thread_contexts[num_threads++]; store_context(regs); /* Subtract 4 to leave room for the PR push in ldctx()