# Heap Corruption while Publishing Shadow Update

**URL:** <https://forums.freertos.org/t/heap-corruption-while-publishing-shadow-update/16641>\
**Category:** Kernel\
**Tags:** debug, aws-iot-core\
**Created:** [January 27, 2023, 11:44pm UTC](https://forums.freertos.org/t/heap-corruption-while-publishing-shadow-update/16641 "2023-01-27T23:44:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surender](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@Surender](https://forums.freertos.org/u/Surender)\
**Post date:** [January 27, 2023, 11:44pm UTC](https://forums.freertos.org/t/heap-corruption-while-publishing-shadow-update/16641/1 "2023-01-27T23:44:15Z")

</div>

![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/c/c57c4406cf54552403114af5f0ce8cb14a3ffee5.png)  
I notice a heap corruption rarely. Not reproduceable everytime while publishing a shadow update. The current set up has a Shadow task which deletes itself after reporting the default device status.

When I turned on the heap debugging in ESP32, I noticed some of the logs which I find difficult to comprehend. Does this mean the heap corruption is caused because of lack enough memory allocated to the task or something else has already corrupted the heap before it comes down the shadow update?

Thanks in Advance.

---

<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:** [January 29, 2023, 3:46pm UTC](https://forums.freertos.org/t/heap-corruption-while-publishing-shadow-update/16641/2 "2023-01-29T15:46:37Z")

</div>

These messages come from [ESP-IDF](https://github.com/espressif/esp-idf/blob/master/components/heap/multi_heap_poisoning.c#L117) and likely indicate some sort of heap corruption. Try these suggestions from Espressif - [Heap Memory Debugging - ESP32 - — ESP-IDF Programming Guide latest documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/heap_debug.html#finding-heap-corruption)
