>> "the program gets stuck in one task, resulting in the system crashing as the watchdog is no longer refreshed. "
Maybe it is about the word 'crashing', but if the watchdog triggers it should do a proper reset/restart of the system and not crash.
What I would do is: in the watchdog routine, keep a counter to detect when the watchdog is about to expire. If it is about to expire, enter an endless loop and keep the watchdog happy. Then attach with the debugger (see https://mcuoneclipse.com/2021/04/25/attach-with-the-debugger-to-a-running-target/ ) and you can see what is wrong in your system.
Otherwise: I hope you are using FreeRTOS, then you can use SEGGER SystemView (see https://mcuoneclipse.com/2015/11/16/segger-systemview-realtime-analysis-and-visualization-for-freert... set it up for post-mortem analysis, let it run into the problem, then attach with the debugger and see what happened.
I hope this helps,
Erich