Using NRF52832 chip + freeRTOS development encounters the problem of getting stuck in idle tasks

I am developing a product that uses the chip of NRF52832 and runs FreeRTOS on the chip to manage my task list.
However, I found that the program would be stuck in the idle task, and it may be that the system had just started to run shortly or after ten or more hours of operation of the system.
I run the following code in vApplicationIdleHook:

void vApplicationIdleHook(void)
{
	__set_FPSCR(__get_FPSCR() & ~(0x0000009F));
	(void) __get_FPSCR();
	NVIC_ClearPendingIRQ(FPU_IRQn);
	if(uxTaskPriorityGet(xTaskGetIdleTaskHandle())!=0)
	{
		APP_ERROR_HANDLER(DEF_ERROR_THREADHEAPFAULT);
	}
}

It is found that he will randomly throw this Error code
Does anyone know what’s going on?

Are you saying that Idle task’s priority is not zero. That should not happen. What is the value of Idle task priority? Why do you have this FPU interrupt related code in Idle hook?

Oh thanks for your reply! The value of the priority change is not unique. I observed that it changed to some exaggerated value such as 164641. Do you mean that it is possible that the above piece of code has modified the idle task priority value?

This seems like a memory corruption. I’d suggest to use data breakpoint to catch what is causing memory corruption.

After discovering this phenomenon, I also reasoned that it was memory corruption and I completely agree with your point of view!!! I hope to get some suggestions, for example, what value can I query for the corresponding address? I have also thought about whether it is possible to use breakpoints for debugging, but since the problem occurs with a small probability, it is difficult to know when it will appear. This phenomenon makes breakpoint debugging difficult. If my thinking is fine, maybe use watch window in the Keil debug to view some values is a feasible way?

TCB has a uxPriority member. Use the address of this member in Idle task’s TCB. This member for Idle task must always be zero. So a write to any other value would be memory coorruption.

You right that you cannot use breakpoints. I suggested to use “data breakpoints” which can help you break the program when a specific memory address is modified. Seems like Keil IDE does support them - µVision User's Guide: Breakpoints Window.

Wow, that’s really interesting. I haven’t used this feature yet. I’ll look into it.

Hello, I have added the following breakpoint settings in keil and the code is running continuously. Is this what your suggestion means?

I think you should change count to 1 and set size to 4 bytes. Rest looks okay. The debugger should now break when the memory corruption happens.