# config assert at heap 5

**URL:** <https://forums.freertos.org/t/config-assert-at-heap-5/2876>\
**Category:** Kernel\
**Created:** [March 10, 2015, 8:48am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876 "2015-03-10T08:48:52Z")\
**Posts on this page:** 11\
**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:** [March 10, 2015, 8:48am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/1 "2015-03-10T08:48:52Z")

</div>

**[crippler1](https://sourceforge.net/u/crippler1/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#7abc):

Hi

I have a problem,

my config assert pops at configASSERT( pxEnd ) in pvPortMalloc function, when I try to create task

it means that pxEnd is not initialized.

any suggestions?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2015, 9:44am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/2 "2015-03-10T09:44:17Z")

</div>

**[andymcc0](https://sourceforge.net/u/andymcc0/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#3958):

Does this provide a clue?

```
void *pvPortMalloc( size_t xWantedSize )
{
BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
void *pvReturn = NULL;

/* The heap must be initialised before the first call to
        prvPortMalloc(). */
configASSERT( pxEnd );

```

i.e. have you called `vPortDefineHeapRegions()` ?

Do you need `heap_5.c` with its segmented, user defined heap?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2015, 9:55am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/3 "2015-03-10T09:55:06Z")

</div>

**[crippler1](https://sourceforge.net/u/crippler1/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#ae33):

at the heap5.c pxEnd = NULL at declaration as static.

I don’t see any change at pxEnd to any non zero value, at the all file.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2015, 10:00am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/4 "2015-03-10T10:00:28Z")

</div>

**[crippler1](https://sourceforge.net/u/crippler1/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#b4ec):

as for the heap5 question

I am new to free rtos and i wrote simple main func that creates a task and runs it.

---

<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:** [March 10, 2015, 10:11am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/5 "2015-03-10T10:11:20Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#23e9):

Andy made some suggestions as to what the problem might be, but I don’t think you have answered either of his questions.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2015, 10:21am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/6 "2015-03-10T10:21:47Z")

</div>

**[crippler1](https://sourceforge.net/u/crippler1/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#ad2c):

I see that vPortDefineHeapRegions() contains the same assert check,  
but I don’t see the code that change the pxEnd before the assert check.

---

<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:** [March 10, 2015, 10:33am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/7 "2015-03-10T10:33:05Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#ad2c/0419):

> I see that vPortDefineHeapRegions() contains the same assert check,

Actually, it doesn’t. It checks pxEnd is NULL to ensure you don’t call  
the function twice.

> but I don’t see the code that change the pxEnd before the assert check.

It is done in vPortDefineHeapRegions().

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2015, 10:39am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/8 "2015-03-10T10:39:37Z")

</div>

**[crippler1](https://sourceforge.net/u/crippler1/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#db0e):

Where is it done?

---

<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:** [March 10, 2015, 10:47am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/9 "2015-03-10T10:47:25Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#db0e/d693):

Didn’t I tell you that in my very last post in this thread?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 10, 2015, 10:52am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/10 "2015-03-10T10:52:07Z")

</div>

**[crippler1](https://sourceforge.net/u/crippler1/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#e90e):

Sorry for the dumb question:

should I use heap for every program that I write?

I have watch some tutorials for free RTOS, and I never saw heap functions at main.

---

<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:** [March 10, 2015, 10:56am UTC](https://forums.freertos.org/t/config-assert-at-heap-5/2876/11 "2015-03-10T10:56:59Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, March 10, 2015](https://sourceforge.net/p/freertos/discussion/382005/thread/8124d8b6/#e90e/9527):

[http://www.freertos.org/a00111.html](http://www.freertos.org/a00111.html)
