STM32 gotchas
81.Crash due to stack content getting corrupted (DMA writes to buffer improperly allocated on stack)

Users sometimes inadvertently allocate a memory-side buffer for DMA as a local non-static variable, i.e. on the stack. They expect this buffer to be filled by a peripheral-to-memory DMA, and then process the data in an interrupt invoked upon completion of DMA.

If they do this in a fuction which subsequently ends while DMA is still running, which is the usual case, this may lead to a surprising crash or any other unexpected program behaviour.

Naturally, the stack gets reused in following function calls, so the running DMA will then corrupt the content of stack.

Counterpart to this issue, related to Tx rather then Rx with perhaps less dramatic consequences, is described here.

One of the instances of this gotcha reported here.