Using the provided sample code for the PIC32 platform and FreeRTOS v202112.00. I ran into an issue in tasks.c when enabling the compiler optimizations (XC32 v4.00 compiler, -O2 optimization).
The exception happens in xTaskResumeAll() when the listREMOVE_ITEM macro tries to remove an item with a null pointer as the container. The macro creates a pointer pxList and de-references it without checking if it is NULL, causing an exception.
In my case, it seemed to be caused by an aggressive compiler and the fix was to add #define configLIST_VOLATILE volatile in FreeRTOSConfig.h
I think nevertheless the pointer should be checked for non-null in the macro to gracefully handle exceptions.
As described in this comment block, the solution you mentioned is right. Thank you for reporting it.
This list is not a general purpose list and meant for internal use only. Wherever we call remove item, it is ensured that the list is not empty. So I am not sure that we need to add an extra NULL check here.
Limited testing suggests that it does solve the problem - I only asked because you said a null check should be added, which made me think you didn’t feel the volatile was the best solution.
Apologies. What I meant in my above response was not adding the check as we always ensure that list is not empty before calling the macro. I have updated my response above.