# xQueueSendToBack stuck in M4 RTOS

**URL:** <https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468>\
**Category:** Kernel\
**Created:** [August 13, 2020, 9:08am UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468 "2020-08-13T09:08:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![reddy](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@reddy](https://forums.freertos.org/u/reddy)\
**Post date:** [August 13, 2020, 9:08am UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/1 "2020-08-13T09:08:26Z")

</div>

Hi All,

I have created rx and tx tasks with priority as 1,2.

My rx task will post item back to Queue using xQueueSendToBack and tx task will receive an item from Queue.

Before posting item to Queue my rx task will perform compression(LZ4) on my data then post item to Queue but after compression of item my rx task always stuck at xQueueSendToBack() func

Can any body faced the same issue. Please help me to find the root cause.

I am using var-som-mini board.

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [August 13, 2020, 10:15am UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/2 "2020-08-13T10:15:13Z")

</div>

So without using compression queuing basically works (with some test data) ?

---

<div class="post-metadata">

**Author:** ![reddy](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@reddy](https://forums.freertos.org/u/reddy)\
**Post date:** [August 13, 2020, 10:33am UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/3 "2020-08-13T10:33:48Z")

</div>

Without compression queuing works. After adding compression only facing this issue.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [August 13, 2020, 10:52am UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/4 "2020-08-13T10:52:27Z")

</div>

My first thought is what exactly are you posting on the queue. Queues deal with fixed length items, so ‘compression’, which tends to give a variable length, doesn’t really seem applicable.

My guess (since we see no code) is that the sending task is adding more data than the receiving task tasks, so the queue fills and blocks.

---

<div class="post-metadata">

**Author:** ![reddy](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@reddy](https://forums.freertos.org/u/reddy)\
**Post date:** [August 13, 2020, 11:56am UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/5 "2020-08-13T11:56:38Z")

</div>

I am not posting compressed length to Queue. Always posting fixed length to Queue.

I am just compressing for an array of of 5 bytes and storing compressed data in other buffer.

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [August 13, 2020, 1:03pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/6 "2020-08-13T13:03:26Z")

</div>

Well, then it seems that the invocation of your compression routine corrupts something maybe due to a stack overflow.  
The Q itself doesn’t care about 5 compressed or uncompressed bytes so the invocation routine is the only difference.  
Did you enable the debug check macros like `configCHECK_FOR_STACK_OVERFLOW` ?

---

<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 13, 2020, 1:27pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/7 "2020-08-13T13:27:47Z")

</div>

Would agree with the above. If sending to the queue works, but performing some unrelated compression then sending to the same queue in the same way doesn’t, it would see that it was the compression operation that was causing the issue - and that was unrelated to the queue send operation if that has not changed. Take a look through the following to see if it helps - it mentions things like stack overflow detection as per hs2’s post: [https://www.freertos.org/FAQHelp.html](https://www.freertos.org/FAQHelp.html)

---

<div class="post-metadata">

**Author:** ![reddy](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@reddy](https://forums.freertos.org/u/reddy)\
**Post date:** [August 13, 2020, 3:05pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/8 "2020-08-13T15:05:57Z")

</div>

After setting configCHECK\_FOR\_STACK\_OVERFLOW to 1 or 2 while compiling facing below error.

tasks.c:(.text.vTaskSwitchContext+0x3e): undefined reference to `vApplicationStackOverflowHook’  
collect2: error: ld returned 1 exit status

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [August 13, 2020, 4:00pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/9 "2020-08-13T16:00:03Z")

</div>

Because you need to define the routine in your code, that is why it begins with Application. Generally I try to print some error message and then halt the program.

---

<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 13, 2020, 8:55pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/10 "2020-08-13T20:55:12Z")

</div>

> [@reddy](#):
>
> vApplicationStackOverflowHook

> **[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

---

<div class="post-metadata">

**Author:** ![reddy](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@reddy](https://forums.freertos.org/u/reddy)\
**Post date:** [August 14, 2020, 1:17pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/11 "2020-08-14T13:17:10Z")

</div>

I have defined vApplicationStackOverflowHook routine in my code and added some dummy log to print the task name.

It doesn’t hit this routine when it stuck after compression.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 14, 2020, 5:19pm UTC](https://forums.freertos.org/t/xqueuesendtoback-stuck-in-m4-rtos/10468/12 "2020-08-14T17:19:48Z")

</div>

As pointed in above replies, the symptoms seems that of a memory corruption. Would you be able to break the code in debugger and see where it is stuck? Also, have you defined `configASSERT`?

Another quick check to ensure that it is not stack overflow is to increase the size of stack and see if the problem persists.

Thanks.
