Idle task stack overflow

tpycke wrote on Saturday, June 13, 2009:

Hi,

To make sure everything is OK during development, I use the stack overflow hook. However, my Idle task stack is overflowing.

Code:
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName )
{
    uart1_puts("Stack overflow! ");
    uart1_puts(pcTaskName);
    uart1_puts("\n\r");
}

Result:
06/13/2009 21:38:52.078 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.093 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.093 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.093 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.125 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.125 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.125 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.125 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.125 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.125 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.140 --> Stack overflow! IDLE                                                                                                                                                                                                        
06/13/2009 21:38:52.140 --> Stack overflow! IDLE 

(doesn’t seem to affect the normalo operation)

Anybody any idea why that is?

Thanks,

Tom

richard_damon wrote on Saturday, June 13, 2009:

It could be that you need to give the IDLE task a bit more stack (perhaps an interrupt function is using more than the demos planed for), or that something else is corrupting the task stack, either through a bad pointer, or some other task declairs a large buffer it doesn;t use all of in a function that corrupts it. My first guess is the interrupt function.

tpycke wrote on Saturday, June 13, 2009:

Thanks,
Do the Idle task and the interrupts share the same stack? How do I make it larger?
Yes, I do use a lot of interrupt handling on top of freertos.

richard_damon wrote on Saturday, June 13, 2009:

Unless the processor has a dedicated stack for interrupt routines (ARM processors do,  many others don’t), then all interrupts will use the stack of whatever task is currently running. In FreeRTOSConfig.h is a define for configMINIMAL_STACK_SIZE which sets the size of the idle task (and most other tasks should set their size based on this plus what additional space they need).

rtel wrote on Friday, December 31, 2010:

On the LPC2000, interrupts use a separate stack (I think most if not all the 32bit FreeRTOS ports use a separate stack for interrupts).  It could be that you interrupt stack is too small and that overflowing is corrupting something else to give you this symptom.  The interrupt stack size (ARM7 IRQ mode stack in this case) is normally set in the C start up code.

Are you using an idle task hook function?  If so, then is that using a lot of stack?

Regards.

jstoezel wrote on Friday, December 31, 2010:

I am getting a similar issue. I haven’t tried the suggested solution yet that consists of increasing configMINIMAL_STACK_SIZE.

Before reading this post, my understanding was too that the interrupts use a different stack, which is set in the startup code. When I saw this issue yesterday I did increase the interrupt stack size, from the default 256 bytes to 512. It didn’t fix the issue though so I ruled out that the ISR is running our of stack.

I do not use a hook on the idle task.