Skip to contentSkip to conversation

xenomai 3.0rc4 rt_heap_alloc replies with timeout

Xenomai Stéphane ANCELOT 3 participants 15 messages Apr 28, 2015 – May 6, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

for unknown reason, using compat api, rt_heap_alloc replies with timeout, or blocks if TM_INFINITE is requested.

I also noticed I don't have /dev/rtheap node, is it normal.?

Regards,
S.Ancelot

#1 lore raw
Quoted 4 lines · Stéphane ANCELOT

Hi,

for unknown reason, using compat api, rt_heap_alloc replies with timeout, or blocks if TM_INFINITE is requested.

Because the request exceeds the available space. The compat api does not wrap rt_heap services, so this is unrelated.

Quoted 3 lines

I also noticed I don't have /dev/rtheap node, is it normal.?

Yes, /dev/rtheap is gone in 3.x.

Signature · 1 line
Philippe.
#2 lore raw

Hi,

Ok, I am using more than one heap, it seems being related .

It is not possible anymore?
Regards,
S.Ancelot

Quoted 12 lines · Philippe Gerum
Quoted 4 lines · Stéphane ANCELOT

Hi,

for unknown reason, using compat api, rt_heap_alloc replies with timeout, or blocks if TM_INFINITE is requested.

Because the request exceeds the available space. The compat api does not wrap rt_heap services, so this is unrelated.

Quoted 2 lines

I also noticed I don't have /dev/rtheap node, is it normal.?

Yes, /dev/rtheap is gone in 3.x.

#3 lore raw
Quoted 4 lines · Stéphane ANCELOT

Hi,

Ok, I am using more than one heap, it seems being related .

I don't think so. This unit test illustrates such case:
http://git.xenomai.org/xenomai-3.git/commit/?h=next&id=fc7a90768c60e59cdc86ed47a42d4757ff2c4d90

Quoted 1 line

It is not possible anymore?

That would be quite a silly decision, isn't it? You should refer to this part of the online migration guide to find out which changes have been introduced in the user-visible interface:

http://xenomai.org/migrating-from-xenomai-2-x-to-3-x/#Heaps

Quoted 20 lines

Regards,
S.Ancelot

Quoted 12 lines · Philippe Gerum
Quoted 4 lines · Stéphane ANCELOT

Hi,

for unknown reason, using compat api, rt_heap_alloc replies with timeout, or blocks if TM_INFINITE is requested.

Because the request exceeds the available space. The compat api does not wrap rt_heap services, so this is unrelated.

Quoted 2 lines

I also noticed I don't have /dev/rtheap node, is it normal.?

Yes, /dev/rtheap is gone in 3.x.

Signature · 1 line
Philippe.
#4 lore raw
Quoted 8 lines · Philippe Gerum
Quoted 4 lines · Stéphane ANCELOT

Hi,

Ok, I am using more than one heap, it seems being related .

I don't think so. This unit test illustrates such case:
http://git.xenomai.org/xenomai-3.git/commit/?h=next&id=fc7a90768c60e59cdc86ed47a42d4757ff2c4d90

Yes, this one rocks.

I found the reason in my application, I created the heap with H_SINGLE (or deprecated H_SHARED) but the block is not being allocated if rt_heap_alloc() func size parameter is 0 . changing size to blocksize works.

Quoted 27 lines
Quoted 1 line

It is not possible anymore?

That would be quite a silly decision, isn't it? You should refer to this part of the online migration guide to find out which changes have been introduced in the user-visible interface:

http://xenomai.org/migrating-from-xenomai-2-x-to-3-x/#Heaps

Quoted 19 lines

Regards,
S.Ancelot

Quoted 12 lines · Philippe Gerum
Quoted 4 lines · Stéphane ANCELOT

Hi,

for unknown reason, using compat api, rt_heap_alloc replies with timeout, or blocks if TM_INFINITE is requested.

Because the request exceeds the available space. The compat api does not wrap rt_heap services, so this is unrelated.

Quoted 2 lines

I also noticed I don't have /dev/rtheap node, is it normal.?

Yes, /dev/rtheap is gone in 3.x.

#5 lore raw

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

At line 190 of the file, depending on the size value of the heap, the program works or not. This looks like corrupted memory problem...

enclose is the c file, I hope you will be able reproduce it. Regards,
Steph

Quoted 44 lines · Stéphane ANCELOT
Quoted 9 lines · Philippe Gerum
Quoted 4 lines · Stéphane ANCELOT

Hi,

Ok, I am using more than one heap, it seems being related .

I don't think so. This unit test illustrates such case:
http://git.xenomai.org/xenomai-3.git/commit/?h=next&id=fc7a90768c60e59cdc86ed47a42d4757ff2c4d90

Yes, this one rocks.

I found the reason in my application, I created the heap with H_SINGLE (or deprecated H_SHARED) but the block is not being allocated if rt_heap_alloc() func size parameter is 0 . changing size to blocksize works.

Quoted 27 lines
Quoted 1 line

It is not possible anymore?

That would be quite a silly decision, isn't it? You should refer to this part of the online migration guide to find out which changes have been introduced in the user-visible interface:

http://xenomai.org/migrating-from-xenomai-2-x-to-3-x/#Heaps

Quoted 19 lines

Regards,
S.Ancelot

Quoted 12 lines · Philippe Gerum
Quoted 4 lines · Stéphane ANCELOT

Hi,

for unknown reason, using compat api, rt_heap_alloc replies with timeout, or blocks if TM_INFINITE is requested.

Because the request exceeds the available space. The compat api does not wrap rt_heap services, so this is unrelated.

Quoted 2 lines

I also noticed I don't have /dev/rtheap node, is it normal.?

Yes, /dev/rtheap is gone in 3.x.

Quoted 4 lines

_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai

-------------- next part --------------
A non-text attachment was scrubbed...
Name: heap_test.cpp
Type: text/x-c++src
Size: 6429 bytes
Desc: not available
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20150505/44cda4a1/attachment.cpp>

#6 lore raw
Quoted 10 lines · Stéphane ANCELOT

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

At line 190 of the file, depending on the size value of the heap, the program works or not.
This looks like corrupted memory problem...

I do not see anything in your reports would could make think of a corrupted memory problem. Are you sure this is not simply a problem in the overhead calculation? Have you tried to call rt_heap_inquire between rt_heap_create and rt_heap_alloc to see if the usablemem field shows a big enough value?

Signature · 1 line
					    Gilles.
#7 lore raw
Quoted 8 lines · Gilles Chanteperdrix
Quoted 7 lines · Stéphane ANCELOT

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

Quoted 9 lines
Quoted 3 lines

At line 190 of the file, depending on the size value of the heap, the program works or not.
This looks like corrupted memory problem...

I do not see anything in your reports would could make think of a corrupted memory problem. Are you sure this is not simply a problem in the overhead calculation? Have you tried to call rt_heap_inquire between rt_heap_create and rt_heap_alloc to see if the usablemem field shows a big enough value?

have a look at the program and the execution. I am a bit surprised that available usablemem is greater than heap size .

execution :
0"002.800| BUG: [main] trace assertion failed:
../heap_test.cpp:251 => "ret == 0"
heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376
heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376
heap size : 36800 heap usablemem: 37376
heap size : 36800 heap usablemem: 37376
heap size : 36800 heap usablemem: 37376
heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376 heap size : 36800 heap usablemem: 37376

program:
#include <iostream>
#include <stdlib.h>
#include <copperplate/traceobj.h> #include <alchemy/task.h> #include <alchemy/heap.h> #include <alchemy/queue.h>

#define HEAPSIZE 16384
#define MSGSIZE 16
#define NMESSAGES (HEAPSIZE / MSGSIZE) #define POOLSIZE (NMESSAGES * sizeof(void *))

static struct traceobj trobj;

using namespace std;

static RT_HEAP heap1, heap2; RT_HEAP_INFO info;

int main(int argc, char *const argv[])

{
    int ret;
    void *p;
    int size;

    traceobj_init(&trobj, argv[0], 0);
    int flags;
    flags = H_FIFO ;
    size = 36800;
    ret = rt_heap_create(&heap2, "progauto1", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);

    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation1", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto2", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation2", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto3", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation3", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);


    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto4", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation4", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);


    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto5", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation5", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);


    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto6", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation6", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);


    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto7", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation7", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto8", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation8", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto9", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation9", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto10", size, flags);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "progauto_simulation10", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    size = 110400;
    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "defprog", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    size = 3200;
    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "tempo", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

size = 824; // size = 824 is failing but changing size to 3200
rocks ...

    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "config", size, flags);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    exit(0);
}
#8 lore raw
Quoted 12 lines · Stéphane ANCELOT
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Stéphane ANCELOT

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

At line 190 of the file, depending on the size value of the heap, the program works or not.
This looks like corrupted memory problem...

Quoted 8 lines
Quoted 6 lines

I do not see anything in your reports would could make think of a corrupted memory problem. Are you sure this is not simply a problem in the overhead calculation? Have you tried to call rt_heap_inquire between rt_heap_create and rt_heap_alloc to see if the usablemem field shows a big enough value?

have a look at the program and the execution. I am a bit surprised that available usablemem is greater than heap size .

The question was not whether usablemem is big enough when the allocation works, but whether it was big enough when the allocation fails.

Signature · 1 line
					    Gilles.
#9 lore raw
In reply to Stéphane ANCELOT
Quoted 4 lines · Stéphane ANCELOT
    size = 824; // size = 824 is failing but changing size to 3200 rocks ...
    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "config", size, flags);
    traceobj_assert(&trobj, ret == 0);

The interesting call to rt_heap_inquire would go here.

All the other ones are irrelevant.

Also, have you tried directly creating the heap with the failing size instead of doing it after creating many useless heaps? Just to reduce the test case.

Quoted 2 lines

cout << " heap size : " << info.heapsize << " heap usablemem: " <<
info.usablemem;

The value you print here do not correspond to the heap you just created. What is the point of this ?

Quoted 8 lines
    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);

    exit(0);
}
Signature · 1 line
					    Gilles.
#10 lore raw
Quoted 14 lines · Gilles Chanteperdrix
Quoted 4 lines · Stéphane ANCELOT
     size = 824; // size = 824 is failing but changing size to 3200 rocks ...
     // --------------------------------------------------------------
     ret = rt_heap_create(&heap2, "config", size, flags);
     traceobj_assert(&trobj, ret == 0);

The interesting call to rt_heap_inquire would go here.

All the other ones are irrelevant.

Also, have you tried directly creating the heap with the failing size instead of doing it after creating many useless heaps? Just to reduce the test case.

Quoted 12 lines
Quoted 2 lines

cout << " heap size : " << info.heapsize << " heap usablemem: " <<
info.usablemem;

The value you print here do not correspond to the heap you just created. What is the point of this ?

Quoted 7 lines
     ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
     traceobj_assert(&trobj, ret == 0);

     exit(0);
}

You are right, reducing the test case, and using this size reports the problem :

output:

root@debian:/home/macsoft# ./heap_regression
   0"002.074| BUG: [main] trace assertion failed:
../heap_test.cpp:34 => "ret == 0"

program:
#include <iostream>
#include <stdlib.h>
#include <copperplate/traceobj.h>
#include <alchemy/task.h>
#include <alchemy/heap.h>
#include <alchemy/queue.h>

#define HEAPSIZE 16384
#define MSGSIZE 16
#define NMESSAGES (HEAPSIZE / MSGSIZE)
#define POOLSIZE (NMESSAGES * sizeof(void *))

static struct traceobj trobj;

using namespace std;

static RT_HEAP heap2;
RT_HEAP_INFO info;

int main(int argc, char *const argv[])

{
    int ret;
    void *p;
    int size;

    traceobj_init(&trobj, argv[0], 0);
    int flags;
    flags = H_FIFO ;


    size = 824; // size = 824 is failing but changing size to 3200 
rocks ...
    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "config", size, flags);
    traceobj_assert(&trobj, ret == 0);

    ret = rt_heap_inquire(&heap2,&info);
    traceobj_assert(&trobj, ret == 0);
    cout << " heap size : " << info.heapsize << " heap usablemem: " << 

info.usablemem;

    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);


    exit(0);
}
#11 lore raw
Quoted 23 lines · Stéphane ANCELOT
Quoted 22 lines · Gilles Chanteperdrix
Quoted 4 lines · Stéphane ANCELOT
    size = 824; // size = 824 is failing but changing size to 3200 rocks ...
    // --------------------------------------------------------------
    ret = rt_heap_create(&heap2, "config", size, flags);
    traceobj_assert(&trobj, ret == 0);

The interesting call to rt_heap_inquire would go here.

All the other ones are irrelevant.

Also, have you tried directly creating the heap with the failing size instead of doing it after creating many useless heaps? Just to reduce the test case.

Quoted 2 lines

cout << " heap size : " << info.heapsize << " heap usablemem: " <<
info.usablemem;

The value you print here do not correspond to the heap you just created. What is the point of this ?

Quoted 3 lines
    ret = rt_heap_alloc(&heap2, size, TM_INFINITE, &p);
    traceobj_assert(&trobj, ret == 0);
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
    exit(0);
}

You are right, reducing the test case, and using this size reports the problem :

This is basic: always try to reduce the test case to be as simple as possible in order to reduce where to search for the problem. Also note that a memory corruption is even less likely than with your previous test case.

Quoted 8 lines

output:

root@debian:/home/macsoft# ./heap_regression
   0"002.074| BUG: [main] trace assertion failed:
../heap_test.cpp:34 => "ret == 0"

Ok, so, in fact the heap creation fails when size is 824, not the heap allocation. Sorry, from the thread subject I had understood rt_heap_alloc was failing. Also, this is a general thing about error
returns: in general the value indicate the reason for the failure. Maybe you could print it?

Signature · 1 line
					    Gilles.
#13 lore raw
In reply to Stéphane ANCELOT
Quoted 11 lines · Stéphane ANCELOT

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

At line 190 of the file, depending on the size value of the heap, the program works or not.
This looks like corrupted memory problem...

The API tells you what happens, it's just that you did not pay attention to return codes:

	flags = H_FIFO ;
	size = 36800;
	size = 824; // size = 824 is failing but changing size to 3200 rocks ...
	ret = rt_heap_create(&heap2, "config", size, flags);

This returns -EINVAL, which is documented for rt_heap_create() as:

* - -EINVAL is returned if @a mode is invalid, or @a heapsz is not in
* the range [2k..2Gb].

Besides, your test code never deletes the heaps it creates, before overwriting the same heap descriptor with the next call to rt_heap_create(). Hopefully your application does not do that.

I'm unsure to understand your reasoning about memory corruption.

Signature · 1 line
Philippe.
#12 lore raw
In reply to Stéphane ANCELOT
Quoted 12 lines · Stéphane ANCELOT
Quoted 11 lines · Gilles Chanteperdrix
Quoted 10 lines · Stéphane ANCELOT

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

At line 190 of the file, depending on the size value of the heap, the program works or not.
This looks like corrupted memory problem...

Quoted 9 lines
Quoted 6 lines

I do not see anything in your reports would could make think of a corrupted memory problem. Are you sure this is not simply a problem in the overhead calculation? Have you tried to call rt_heap_inquire between rt_heap_create and rt_heap_alloc to see if the usablemem field shows a big enough value?

have a look at the program and the execution. I am a bit surprised that available usablemem is greater than heap size .

You should not. For best performances, some allocation algorithms may round the requested size for a memory pool up, provided they allocate the backing memory. Whether this increase should be reported to the user depends on the implementation, the current one does so.

Signature · 1 line
Philippe.
#14 lore raw
In reply to Philippe Gerum

right. This is fixed using create size >= 2048 bytes.

Quoted 31 lines · Philippe Gerum
Quoted 11 lines · Stéphane ANCELOT

Hi,
unfortunately, There is something wrong for unknown reason using these functions.

I made a simple regression program that only create heaps and allocates area.

At line 190 of the file, depending on the size value of the heap, the program works or not.
This looks like corrupted memory problem...

The API tells you what happens, it's just that you did not pay attention to return codes:

	flags = H_FIFO ;
	size = 36800;
	size = 824; // size = 824 is failing but changing size to 3200 rocks ...
	ret = rt_heap_create(&heap2, "config", size, flags);

This returns -EINVAL, which is documented for rt_heap_create() as:

* - -EINVAL is returned if @a mode is invalid, or @a heapsz is not in
* the range [2k..2Gb].

Besides, your test code never deletes the heaps it creates, before overwriting the same heap descriptor with the next call to rt_heap_create(). Hopefully your application does not do that.

I'm unsure to understand your reasoning about memory corruption.