esp_core_dump_get_summary returns the wrong cause of the exception (IDFGH-12775) #13754
Closed
3 tasks done
Labels
Resolution: NA
Issue resolution is unavailable
Status: Done
Issue is done internally
Type: Bug
bugs in IDF
Answers checklist.
IDF version.
v5.2.1
Espressif SoC revision.
ESP32-S3 N16R2
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
CMD
Development Kit.
Custom Board
Power Supply used.
Battery
What is the expected behavior?
I expected the ESP-IDF function
esp_core_dump_get_summary
to fill theesp_core_dump_summary_t
struct with the summary of the core dumpWhat is the actual behavior?
Instead the ESP-IDF function
esp_core_dump_get_summary
fills theesp_core_dump_summary_t
but the memberesp_core_dump_summary_extra_info_t
has the wrong value of cause of exceptionSteps to reproduce.
esp_core_dump_get_summary
to get a struct of the core sump summaryex_info.exc_cause
of the returned summaryex_info.exc_cause
does not correpond with theGuru Meditation Error
that prints when the exception occursDebug Logs.
More Information.
I think the problem is with the implementation of the function
elf_parse_version_info
inside ofesp_core_dump_get_summary
in the\components\espcoredump\src\core_dump_elf.c
moduleThe function uses the following line to copy the value of the coredump that was stored in flash and in ELF format to the given struct
memcpy(summary->app_elf_sha256, version->app_elf_sha256, ELF_APP_SHA256_SIZE);
But the struct defines its member
uint8_t app_elf_sha256[APP_ELF_SHA256_SZ];
with a size given by#define APP_ELF_SHA256_SZ (CONFIG_APP_RETRIEVE_LEN_ELF_SHA + 1)
The size of
ELF_APP_SHA256_SIZE
is set to 66 which can be bigger thanAPP_ELF_SHA256_SZ
which defaults to 9 and its calculated from theCONFIG_APP_RETRIEVE_LEN_ELF_SHA
given by the user in the menuconfig.This causes that the memcpy to overflow into the
esp_core_dump_summary_extra_info_t ex_info
member of theesp_core_dump_summary_t
structI fixed the problem by changing the memcpy line to the following
memcpy(summary->app_elf_sha256, version->app_elf_sha256, APP_ELF_SHA256_SZ);
and i had to add the following line to the file cause it doesn't have access to the
APP_ELF_SHA256_SZ
definition#define APP_ELF_SHA256_SZ (CONFIG_APP_RETRIEVE_LEN_ELF_SHA + 1)
I'm happy to provide a pull request with this change.
The text was updated successfully, but these errors were encountered: