# vTaskDelay no return after blocking operation.

**URL:** <https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749>\
**Category:** Kernel\
**Created:** [August 23, 2017, 3:28pm UTC](https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749 "2017-08-23T15:28:48Z")\
**Posts on this page:** 5\
**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:** [August 23, 2017, 3:28pm UTC](https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749/1 "2017-08-23T15:28:48Z")

</div>

**[matita87](https://sourceforge.net/u/matita87/)** wrote on [Wednesday, August 23, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/8f2b0cad/#9f8d):

Hi all,  
I using FreeRTOS V9.0.0 on STM32F4 microcontroller for TFTP server.  
The vTaskDelay never return when it is call after a blocking operation (e.g. after xQueueGenericReceive())  
In details, the TFTP listening task is:

void TFTPserverlistening(void pArgs)  
{  
// Create a socket  
// Bind it to the desired port and protocol  
// Neverending loop  
while (1)  
{  
vTaskDelay(1000); //this works  
/ wait for a connection request (wait a file to upload) - lwip stack /  
n = recvfrom(sd, &args-\>request, TFTPMAXMSGLEN, 0, (struct sockaddr )&args-\>from, (socklent )&fromlen);  
vTaskDelay(1000); // **this dosen’t work - NO RETURN**  
}

where the recvfrom is define as lwip\_recvfrom.  
The lwip\_recvfrom is part of the lwipstack which use the xQueueGenericReceive in order to wait forever a incoming message.  
Similar problem can be obtain calling tow time the vTaskDelay with very long dela:  
vTaskDelay(10000); //this works, yep for 10 seconds it works 🙂  
vTaskDelay(1000); // **this dosen’t work - NO RETURN**

Debugging the vTaskDelay and using the trace data log (with keil) I don’t have see any problem,

Thanks all.  
m

---

<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:** [August 23, 2017, 3:38pm UTC](https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749/2 "2017-08-23T15:38:04Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, August 23, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/8f2b0cad/#9f8d/89b5):

Possibilities for vTaskDelay() never returning would be:

1. The task that called vTaskDelay() is being starved out by higher  
priority tasks that never block.

2. The tick interrupt is not running (when the issue occurs, inspect the  
xTickCount variable or set a break point in the SysTick\_Handler() ISR  
function or xTaskIncrementTick function to see if the tick count is  
still incrementing).

3. You have an old fashioned data corruption that has messed up the  
linked list from which the task is being referenced. Do you have  
configASSERT() defined? Do you have stack overflow protection turned on?

If everything works fine until recvfrom() is called then have a good  
look at that function to make sure there is no way it could exit with  
interrupts disabled, or from inside a critical section.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 24, 2017, 9:17am UTC](https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749/3 "2017-08-24T09:17:35Z")

</div>

**[matita87](https://sourceforge.net/u/matita87/)** wrote on [Thursday, August 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/8f2b0cad/#1175):

Hi  
Thank you for the reply

1. I don’t get your seggestion. Do you think it could be a problem related to priority? The TFTPserverlistening task is created in main function with priority = 6.
2. During vTaskDelay running (never exiting) the system is alive (it is not in halt). The system tick Timer is runinng and the SysTick\_Handler(void) routine is correctly executed (xTickCount is incrementing). Even the vApplicationIdleHook is running.
3. Where I can check if the configASSERT() and stack overflow protection are defined?
4. Yes, I am sure that the recvfrom() exit with all interrupts enable.  
Thanks  
m

---

<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:** [August 24, 2017, 2:39pm UTC](https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749/4 "2017-08-24T14:39:11Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, August 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/8f2b0cad/#1175/3cb1):

> 1. I don’t get your seggestion. Do you think it could be a problem  
> related to priority? The TFTPserverlistening task is created in main  
> function with priority = 6.

I thought that was a possibility, but as you say that  
vApplicationIdleHook() is running it seems that is not the case.

> 1. During vTaskDelay running (never exiting) the system is alive (it is  
> not in halt). The system tick Timer is runinng and the  
> SysTick\_Handler(void) routine is correctly executed (xTickCount is  
> incrementing). Even the vApplicationIdleHook is running.

That is very curious then. Are you 100% sure vTaskDelay() is not  
returning? Have you tried taking a trace recording?  
([FreeRTOS+Trace from Percepio is a sophisticated diagnostic tool for FreeRTOS](http://www.freertos.org/trace))

> 1. Where I can check if the configASSERT() and stack overflow protection  
> are defined?

See the following links (and read the book):

> **[FreeRTOS - The Free RTOS configuration constants and configuration options -...](https://www.freertos.org/a00110.html#configASSERT)**
>
> FreeRTOS is a portable, open source, mini Real Time kernel. A free RTOS for small embedded systems. This page describes and explains the constants used to configure FreeRTOS.

> **[FreeRTOS - stacks and stack overflow checking](https://www.freertos.org/Stacks-and-stack-overflow-checking.html)**
>
> FreeRTOS is a portable, open source, mini Real Time kernel. A free RTOS for small embedded systems

> **[Free RTOS Book and Reference Manual](https://www.freertos.org/Documentation/RTOS_book.html)**
>
> RTOS book

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [August 25, 2017, 9:41am UTC](https://forums.freertos.org/t/vtaskdelay-no-return-after-blocking-operation/6749/5 "2017-08-25T09:41:41Z")

</div>

**[matita87](https://sourceforge.net/u/matita87/)** wrote on [Friday, August 25, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/8f2b0cad/#f8d3):

OK  
thanks  
Regads
