STM32 Sleep Mode: Interrupt gets executed but the CPU stays in WFI
Check if the SLEEPONEXIT bit in SCB-&gt;SCR is set. Setting that to 1 would cause exactly what you've described:

Bit 1 SLEEPONEXIT
Configures sleep-on-exit when returning from Handler
mode to Thread mode. Setting this bit to 1 enables an interrupt-driven
application to avoid returning to an empty main application.
0: Do not
sleep when returning to Thread mode.
1: Enter sleep, or deep sleep, on
return from an interrupt service routine.