I have a project running off a Bluepill board (STM32F103C8T6) that ceases to function only after it runs for ~6 hours. Up to that point it behaves totally normally, and UART logs don't indicate anything out of the ordinary until it just stops. This has made it very painful to debug since it's so difficult to gather information and attempt iterative solutions.
The only lead I have is that when I find the device in the hang state, it cannot be reset properly. In the first few (correct) hours of operation, rebooting the device plays a speaker and blinks an LED. After the hang, resetting results in a solid LED - no sound, and no operation past that point.
Only when I power cycle the device does it return to normal operation, and then everything works exactly as I want it to for another ~6h before it hangs again.
Conventional wisdom would suggest this is a memory leak or a timer overflow, but I don't see how either of those could persist past a system reset! The Bluepill is attached to I2C and SPI devices, but even when those are removed from/returned to the circuit it does not reset properly, and there's nothing else in the circuit that can hold state. I've also heard that an unconnected VBAT could cause this but it's connected to VDD, and reading the datasheet shows no unexpected NRST behaviors.
I'm reluctant to post all 250 lines of code for this project because I haven't been able to narrow down the cause of this at all, so I'm trying to stay general with this question. What kinds of code bugs are capable of surviving an MCU pin-based reset, but not a power cycle?
EDIT: This is terrible form for stack overflow but here is a pastebin of the code. I hope to condense this to only the problematic code ASAP but due to the massive repro time I've had issues narrowing it down. https://pastebin.com/nKDyzRKa