Cortex-A9 port cause FreeRTOS_Undefined exception

supergaute wrote on Sunday, November 25, 2018:

After some more investigation I found out the stack trace changes when I disable optimizations.

The stack trace now becomes this:

Thread #1 57005 (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)	
	FreeRTOS_Undefined() at port_asm_vectors.S:96 0x30000040	
	ucHeap() at 0x31400994	

I also found that the line causing the problem is in tasks.c.
The macro traceTASK_CREATE( ) in the function prvAddNewTaskToReadyList() is defined by Tracealyzer, and it contains calls to portSET_INTERRUPT_MASK_FROM_ISR() and portCLEAR_INTERRUPT_MASK_FROM_ISR().

If I remove the portSET_INTERRUPT_MASK_FROM_ISR() and portCLEAR_INTERRUPT_MASK_FROM_ISR() calls, everything works ok.

If I don’t use Tracealyzer, I can mimic the same behaviour by adding

uint32_t irq_status = portSET_INTERRUPT_MASK_FROM_ISR();
portCLEAR_INTERRUPT_MASK_FROM_ISR(irq_status);

or

portDISABLE_INTERRUPTS();
portENABLE_INTERRUPTS();

after the traceTASK_CREATE() call.
It will execute around 1000 -2000 times before it crashes.

What can be the issue here?