How to effectively handle infinite loops? #430
-
Hello, I have successfully implemented most of Berry support into our firmware and now I am wondering how can I effectively detect infinite loops and stop them. But even after decreasing it to as down as value 2, I still get stuck in an infinite loop. The good thing is that it triggers the ESP watchdog, so one possible solution is clearing the saved Berry code if the reset reason was WDT task. However, this could bring up unwanted behaviour. Any other ideas or experience, maybe the way you handle it in Tasmota? @s-hadinger Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Sure, the heartbeat is managed here: https://github.com/arendst/Tasmota/blob/4fbe3590bea16b3d43fc870bda13807e5d223534/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino#L292-L301 And the observability callback is registered here: So every 1 million instructions, it has the opportunity to raise an exception and kill the infinite loop. |
Beta Was this translation helpful? Give feedback.
Sure, the heartbeat is managed here: https://github.com/arendst/Tasmota/blob/4fbe3590bea16b3d43fc870bda13807e5d223534/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino#L292-L301
And the observability callback is registered here:
be_set_obs_hook(berry.vm, &BerryObservability); /* attach observability hook */
So every 1 million instructions, it has the opportunity to raise an exception and kill the infinite loop.