configLIST_VOLATILE required - Missing configASSERT in listREMOVE_ITEM

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.

Thanks for posting the query.
There are some similar posts in the following threads:

  1. Stuck in xTaskResumeAll() - Interrupt Priorities? Stack?
  2. Endless loop in 10.4.6 with -Os flag
    Please check if any of the suggested options help in your scenario.

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 sure that we need to add an extra NULL check here.