diff --git a/src/thread/thread.c b/src/thread/thread.c index a55f2c4..f7038ca 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -343,6 +343,24 @@ void __attribute__((constructor)) setup_main_thread() { TRACE("premain"); // Create an entry for the main thread. + + struct context_entry_t *new_entry; + for (int i = 0; i < 1000; ++i) { + + new_entry = malloc(sizeof(*new_entry)); + memset(new_entry->stack, 0, STACK_SIZE); + + new_entry->context.uc_stack.ss_sp = new_entry->stack; + new_entry->context.uc_stack.ss_size = STACK_SIZE; + new_entry->context.uc_stack.ss_flags = 0; + + // Tell Valgrind that the memory area of the future stack is a stack + new_entry->valgrind_id = VALGRIND_STACK_REGISTER( + new_entry->context.uc_stack.ss_sp, + new_entry->context.uc_stack.ss_sp + new_entry->context.uc_stack.ss_size); + TAILQ_INSERT_TAIL(&context_to_freed, new_entry, link); + } + struct context_entry_t* main = malloc(sizeof(*main)); // memset(main, 0, sizeof(*main)); getcontext(&main->context);