From 2524583ddacbf95af3b88f15beecdb72794e3ba2 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Sun, 13 Oct 2024 15:52:45 +0800 Subject: [PATCH] AP_HAL_ChibiOS: increase the number of memory regions for crashdump also checks num region overruns for bss and heap --- libraries/AP_HAL_ChibiOS/hwdef/common/crashdump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/crashdump.c b/libraries/AP_HAL_ChibiOS/hwdef/common/crashdump.c index 8c60109e8b..49e3d9f131 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/crashdump.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/crashdump.c @@ -97,7 +97,7 @@ const CrashCatcherMemoryRegion* CrashCatcher_GetMemoryRegions(void); const CrashCatcherMemoryRegion* CrashCatcher_GetMemoryRegions(void) { // do a full dump if on serial - static CrashCatcherMemoryRegion regions[60] = { + static CrashCatcherMemoryRegion regions[80] = { {(uint32_t)&__ram0_start__, (uint32_t)&__ram0_end__, CRASH_CATCHER_BYTE}, {(uint32_t)&ch_system, (uint32_t)&ch_system + sizeof(ch_system), CRASH_CATCHER_BYTE}}; uint32_t total_dump_size = dump_size + buf_off + REMAINDER_MEM_REGION_SIZE; @@ -138,7 +138,7 @@ const CrashCatcherMemoryRegion* CrashCatcher_GetMemoryRegions(void) // log statically alocated memory int32_t bss_size = ((uint32_t)&__bss_end__) - ((uint32_t)&__bss_base__); int32_t available_space = stm32_crash_dump_max_size() - total_dump_size; - if (available_space < 0) { + if (available_space < 0 || curr_region >= (ARRAY_SIZE(regions) - 1)) { // we can't log anymore than this goto finalise; } @@ -157,7 +157,7 @@ const CrashCatcherMemoryRegion* CrashCatcher_GetMemoryRegions(void) // dump the Heap as well as much as we can int32_t heap_size = ((uint32_t)&__heap_end__) - ((uint32_t)&__heap_base__); available_space = stm32_crash_dump_max_size() - total_dump_size; - if (available_space < 0) { + if (available_space < 0 || curr_region >= (ARRAY_SIZE(regions) - 1)) { // we can't log anymore than this goto finalise; }