From 9dc6d8dd8ab1d79e5f0de87157e874f1ffb486f0 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 18 Jul 2020 14:30:29 -0400 Subject: [PATCH] refactor: arch_context_unused error handling --- runtime/include/arch/aarch64/context.h | 2 ++ runtime/include/arch/x86_64/context.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/include/arch/aarch64/context.h b/runtime/include/arch/aarch64/context.h index 067a7d4..a03a233 100644 --- a/runtime/include/arch/aarch64/context.h +++ b/runtime/include/arch/aarch64/context.h @@ -15,6 +15,8 @@ static inline void arch_context_init(struct arch_context *actx, reg_t ip, reg_t sp) { + assert(actx->variant == arch_context_unused); + memset(&actx->mctx, 0, sizeof(mcontext_t)); memset((void *)actx->regs, 0, sizeof(reg_t) * ureg_count); diff --git a/runtime/include/arch/x86_64/context.h b/runtime/include/arch/x86_64/context.h index 5a0857c..95bbbf4 100644 --- a/runtime/include/arch/x86_64/context.h +++ b/runtime/include/arch/x86_64/context.h @@ -72,7 +72,7 @@ arch_context_switch(struct arch_context *current, struct arch_context *next) if (next == NULL) next = &worker_thread_base_context; /* Assumption: The context we are switching to should have saved a context in some form */ - assert(next->variant == arch_context_fast || next->variant != arch_context_unused); + assert(next->variant == arch_context_fast || next->variant == arch_context_slow); reg_t *current_registers = current->regs, *next_registers = next->regs; assert(current_registers && next_registers);