In our university lab we intensively use FreeRTOS.
Students frequently write code that allows the flow of control
to leave a task function. On the ARM Cortex (as in other families)
this creates a crash that may be hard to track down.
To help debugging I use a hook-function that is called
whenever this problem arises. This hook’s address must
be put into the stack-frame when setting up the
task’s stack on creation of a task.
Alternatively you can also link a function that let’s
the task delete itself on exit with the same mechanism.