From b2733a3810072049726710d0c118d68f35318bae Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 9 Mar 2023 00:09:20 +0100 Subject: [PATCH] fix (stack-tracing): added NULL reference check for current process --- kernel/src/mm/stack.c | 6 +++++- kernel/src/utils/panic.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/src/mm/stack.c b/kernel/src/mm/stack.c index a13d4ef..47be71f 100644 --- a/kernel/src/mm/stack.c +++ b/kernel/src/mm/stack.c @@ -32,10 +32,14 @@ void stack_dump_call_info(uint64_t rip, symbol_T* symbol) { void stack_trace_call_stack(uint64_t rbp) { uint64_t rip = ((uint64_t*)rbp)[1]; process_T* process = scheduler_get_current_process(); + if (process == NULL) { + log(LOG_NONE, " 0x%x -> (process NULL reference)", rip); + return; + } symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, rip); if (symbol == NULL) { - log(LOG_NONE, " 0x%x -> ", rip); + log(LOG_NONE, " 0x%x -> (symbol NULL reference)", rip); return; } diff --git a/kernel/src/utils/panic.c b/kernel/src/utils/panic.c index 023ae22..01daadf 100644 --- a/kernel/src/utils/panic.c +++ b/kernel/src/utils/panic.c @@ -91,7 +91,7 @@ void panic_log_call_stack(cpu_state_T* state) { symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, state->rip); if (symbol == NULL) { - log(LOG_NONE, " 0x%x -> ", state->rip); + log(LOG_NONE, " 0x%x -> (symbol NULL reference)", state->rip); return; }