Allocated memory corrupted in Interruptroutine?
Hello Community,
I'm developing a program for a STM32 L051R6T6 with CubeIDE.on bare metal, using HAL driver functions.
It reads some cyclic data from two USARTS using DMA.
The maincycle does processing of the rxTelegrams, transmits and does some logging on a third LPUART.
I now I'm experiencing problems with longer logstrings. They are allocated from heap with malloc with necessary size (500 Bytes in my case and checked for NULL). But while the maincycle fills it with logging content, a DMA Interrupt occures and process the DMAData from one of the USARTs. In the Interrupt routine a function is called and when I step with the debugger from this function header to the first instruction, my allocated logbuffer from the maincycle is overwritten with 24 Bytes near the end.
My questions are:
Shouldn't the allocated memory from the maincycle also be protected from overwriting in Interrupt routines? If not: how could I avoid such behavior.
What is done, when I jump from the function header to the first instruction in debugger. Is this the creation step of the values of function parameters ( the content of the 24 Bytes doesnt look like the parameters, as far as i can tell).
Of course there may be memory leaks in the program, but in this case all seems to be valid.
Thank you.
