# vApplicationStackOverflowHook

**URL:** <https://forums.freertos.org/t/vapplicationstackoverflowhook/7880>\
**Category:** Kernel\
**Created:** [May 26, 2019, 9:49am UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880 "2019-05-26T09:49:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 26, 2019, 9:49am UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880/1 "2019-05-26T09:49:10Z")

</div>

**[ftsi](https://sourceforge.net/u/ftsi/)** wrote on [Sunday, May 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/aec06cd6c7/#62c9):

Hi  
i would like to create just 2 tasks. But i gor error of vApplicationStackOverflowHook.

```auto
#include "stm32f30x.h"
#include "FreeRTOS.h"
#include "task.h"
//Task functions prototypes
void vTask1_handlder(void *params);
void vTask2_handlder(void *params);

TaskHandle_t xTaskHandle1 = NULL;
TaskHandle_t xTaskHandle2 = NULL;

int main(void)
{
	//1. Reset the RCC clock configuration to the default reset state
	//HSI ON,PLL OFF, HSE OFF, system clock = 8 MHz
	RCC_DeInit();

	//2. update the SystemCoreClock variable
	SystemCoreClockUpdate();

	xTaskCreate(vTask1_handlder, "Task-1",configMINIMAL_STACK_SIZE,NULL,2,&xTaskHandle1);

	xTaskCreate(vTask2_handlder, "Task-2",configMINIMAL_STACK_SIZE,NULL,2,&xTaskHandle2);
	for(;;);
}

void vTask1_handlder(void *params)
{
while(1);
}

void vTask2_handlder(void *params)
{
while(1);
}

```

as far as I know, this kind of error are connected with FreeRTOSConfig.h. I search something in the forum but changing some parameters value like configUSE\_MALLOC\_FAILED\_HOOK, configCHECK\_FOR\_STACK\_OVERFLOW, i have never solved the issues.  
The compiler gives me:

```auto
d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: STM32_HelloWorld.elf section `.bss' will not fit in region `RAM'
d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 13736 bytes
Third-Party/FreeRTOS/ong/Source/tasks.o: In function `vTaskSwitchContext':
D:\Workspace\RTOS_workspace\STM32_HelloWorld\Debug/../Third-Party/FreeRTOS/ong/Source/tasks.c:2988: undefined reference to `vApplicationStackOverflowHook'
collect2.exe: error: ld returned 1 exit status
makefile:38: recipe for target 'STM32_HelloWorld.elf' failed
make: *** [STM32_HelloWorld.elf] Error 1

```

My Config file is:

```auto
....
#include "stm32f30x.h"
extern uint32_t SystemCoreClock;

#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0// it was 1
#define configCPU_CLOCK_HZ (SystemCoreClock)
#define configTICK_RATE_HZ ((portTickType) 1000)
#define configMAX_PRIORITIES (5) //it was ((unsigned portBASE_TYPE) 5)
#define configMINIMAL_STACK_SIZE ((unsigned short) 130)
#define configTOTAL_HEAP_SIZE ((size_t) (75 * 1024))
#define configMAX_TASK_NAME_LEN (10)
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 8
#define configCHECK_FOR_STACK_OVERFLOW 2 // it was 2
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configGENERATE_RUN_TIME_STATS 0

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES (2)

/* Software timer definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (2)
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
...

```

thanks in advance  
Fausto

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 26, 2019, 10:26am UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880/2 "2019-05-26T10:26:12Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Sunday, May 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/aec06cd6c7/#62c9/e0f7):

I would definitely not expect a stack overflow with those settings as your tasks do not allocate any stack variables or call any functions. When does the stack overflow occur? Do the tasks ever start? Which compiler are you using and what is the optimization set to?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 26, 2019, 11:13am UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880/3 "2019-05-26T11:13:03Z")

</div>

**[richarddamon](https://sourceforge.net/u/richarddamon/)** wrote on [Sunday, May 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/aec06cd6c7/#3f48):

You are getting a link error saying you haven;t defined vApplicationStackOverflowHook but you have configured FreeRTOS to call it because you have set configCHECK\_FOR\_STACK\_OVERFLOW to 2.

You need to define the function vApplicationStackOverflowHook.

If you program is being written in C++, it also needs to be declared inside an extern “C” block, or it won’t have the right name.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 26, 2019, 11:29am UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880/4 "2019-05-26T11:29:27Z")

</div>

**[ftsi](https://sourceforge.net/u/ftsi/)** wrote on [Sunday, May 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/aec06cd6c7/#62c9/e0f7/a055):

Hi  
I m using System Workbench of ST. The compiler is Ac6 STM32 MCU GCC.  
As you can understand, i’m new with FreeRTOS and for me some names are unknown.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 26, 2019, 11:40am UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880/5 "2019-05-26T11:40:46Z")

</div>

**[ftsi](https://sourceforge.net/u/ftsi/)** wrote on [Sunday, May 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/aec06cd6c7/#af3a):

the appear in the file task,c in the void vTaskSwitchContext( void ) when the fucntion calls the function taskCHECK\_FOR\_STACK\_OVERFLOW()  
compiler : undefined reference to vApplicationStackOverflowHook’.  
if i set configCHECK\_FOR\_STACK\_OVERFLOW to 0, i have error of RAM:

```auto
d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: STM32_HelloWorld.elf section `.bss' will not fit in region `RAM'
d:/openstm32/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 13736 bytes
collect2.exe: error: ld returned 1 exit status
makefile:38: recipe for target 'STM32_HelloWorld.elf' failed
make: *** [STM32_HelloWorld.elf] Error 1

```

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 26, 2019, 11:10pm UTC](https://forums.freertos.org/t/vapplicationstackoverflowhook/7880/6 "2019-05-26T23:10:24Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Sunday, May 26, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/aec06cd6c7/#af3a/ca00):

As Richard D said, if you want to use stack overflowing (which you  
definitely should during development) then YOU need to implement  
vApplicationStackOverflowHook(). Anything that starts “Application” is  
the responsibility of the application writer. First link:

[https://www.google.com/search?q=vApplicationStackOverflowHook](https://www.google.com/search?q=vApplicationStackOverflowHook)

Also as Richard D says, the second error you are getting is that you are  
trying to allocate 13KBytes more RAM than the linker script part says  
you have available - so you need to reduce the RAM (this is nothing to  
do with FreeRTOS by the way, but reducing the size of the heap allocated  
to FreeRTOS may be all you need to do).

[https://www.freertos.org/Documentation/RTOS\_book.html](https://www.freertos.org/Documentation/RTOS_book.html)
