Issue with Memory Corruption in output_class_buffer - Adjacent Registers Affected
Hello,
I am facing a serious issue in my STM32 project related to the neai_classification function. Here's the context of my code:
When calling the function neai_classification(inst_current, output_class_buffer, &id_class);, I observe that the output_class_buffer contains very strange values (such as 0.72333524e-24), which don't make sense. More troubling, however, is that not only does output_class_buffer contain these weird values, but adjacent variables and registers are also being corrupted in the process.
In particular, variables that are adjacent to output_class_buffer are getting overwritten with unexpected values. This corruption extends to other variables in the program, causing them to hold invalid data, which in turn disrupts the application’s logic.
Details:
- The output_class_buffer is aligned with __attribute__((aligned(4))), to ensure proper memory alignment.
- The issue seems to be directly linked to the classification function modifying adjacent memory regions, leading to corruption of other variables.
- The corrupted values in the output_class_buffer include values like 0.72333524e-24, which are not expected in the context of the data being handled.
- It seems that the adjacent registers or memory locations are being incorrectly modified, affecting not just the buffer but also other program variables.
Questions:
- Is there a possibility of a memory overflow or corruption happening due to incorrect buffer size or alignment?
- Could this be related to the alignment of output_class_buffer or how memory is managed in the STM32 environment?
- How can I debug or prevent this issue of adjacent memory corruption?
- Has anyone encountered similar problems with buffer corruption in STM32, especially when working with classification functions?
I would greatly appreciate any insights or suggestions on how to resolve this issue.
