fix (stack-tracing): added NULL reference check for current process

This commit is contained in:
antifallobst 2023-03-09 00:09:20 +01:00
parent 0e0e5cf154
commit b2733a3810
2 changed files with 6 additions and 2 deletions

View File

@ -32,10 +32,14 @@ void stack_dump_call_info(uint64_t rip, symbol_T* symbol) {
void stack_trace_call_stack(uint64_t rbp) { void stack_trace_call_stack(uint64_t rbp) {
uint64_t rip = ((uint64_t*)rbp)[1]; uint64_t rip = ((uint64_t*)rbp)[1];
process_T* process = scheduler_get_current_process(); process_T* process = scheduler_get_current_process();
if (process == NULL) {
log(LOG_NONE, " 0x%x -> <failed to resolve symbol> (process NULL reference)", rip);
return;
}
symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, rip); symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, rip);
if (symbol == NULL) { if (symbol == NULL) {
log(LOG_NONE, " 0x%x -> <failed to resolve symbol>", rip); log(LOG_NONE, " 0x%x -> <failed to resolve symbol> (symbol NULL reference)", rip);
return; return;
} }

View File

@ -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); symbol_T* symbol = symbol_resolve_function_from_rip(process->executable->symbols, process->executable->num_symbols, state->rip);
if (symbol == NULL) { if (symbol == NULL) {
log(LOG_NONE, " 0x%x -> <failed to resolve symbol>", state->rip); log(LOG_NONE, " 0x%x -> <failed to resolve symbol> (symbol NULL reference)", state->rip);
return; return;
} }