All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
@ 2015-04-28 15:50 Stéphane ANCELOT
  2015-04-28 17:25 ` Philippe Gerum
  0 siblings, 1 reply; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-04-28 15:50 UTC (permalink / raw)
  To: xenomai

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


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-04-28 15:50 [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout Stéphane ANCELOT
@ 2015-04-28 17:25 ` Philippe Gerum
  2015-04-30  7:08   ` Stéphane ANCELOT
  0 siblings, 1 reply; 15+ messages in thread
From: Philippe Gerum @ 2015-04-28 17:25 UTC (permalink / raw)
  To: Stéphane ANCELOT, xenomai

On 04/28/2015 05:50 PM, Stéphane ANCELOT wrote:
> 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.

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

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

-- 
Philippe.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-04-28 17:25 ` Philippe Gerum
@ 2015-04-30  7:08   ` Stéphane ANCELOT
  2015-04-30  8:34     ` Philippe Gerum
  0 siblings, 1 reply; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-04-30  7:08 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

Hi,

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

It is not possible anymore?
Regards,
S.Ancelot



On 28/04/2015 19:25, Philippe Gerum wrote:
> On 04/28/2015 05:50 PM, Stéphane ANCELOT wrote:
>> 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.
>
>> I also noticed I don't have /dev/rtheap node, is it normal.?
>>
> Yes, /dev/rtheap is gone in 3.x.
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-04-30  7:08   ` Stéphane ANCELOT
@ 2015-04-30  8:34     ` Philippe Gerum
  2015-04-30 12:30       ` Stéphane ANCELOT
  0 siblings, 1 reply; 15+ messages in thread
From: Philippe Gerum @ 2015-04-30  8:34 UTC (permalink / raw)
  To: Stéphane ANCELOT, xenomai

On 04/30/2015 09:08 AM, Stéphane ANCELOT wrote:
> 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

> 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

> Regards,
> S.Ancelot
> 
> 
> 
> On 28/04/2015 19:25, Philippe Gerum wrote:
>> On 04/28/2015 05:50 PM, Stéphane ANCELOT wrote:
>>> 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.
>>
>>> I also noticed I don't have /dev/rtheap node, is it normal.?
>>>
>> Yes, /dev/rtheap is gone in 3.x.
>>
> 
> 


-- 
Philippe.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-04-30  8:34     ` Philippe Gerum
@ 2015-04-30 12:30       ` Stéphane ANCELOT
  2015-05-05 13:37         ` Stéphane ANCELOT
  0 siblings, 1 reply; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-04-30 12:30 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 30/04/2015 10:34, Philippe Gerum wrote:
> On 04/30/2015 09:08 AM, Stéphane ANCELOT wrote:
>> 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.
>> 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
>
>> Regards,
>> S.Ancelot
>>
>>
>>
>> On 28/04/2015 19:25, Philippe Gerum wrote:
>>> On 04/28/2015 05:50 PM, Stéphane ANCELOT wrote:
>>>> 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.
>>>
>>>> I also noticed I don't have /dev/rtheap node, is it normal.?
>>>>
>>> Yes, /dev/rtheap is gone in 3.x.
>>>
>>
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-04-30 12:30       ` Stéphane ANCELOT
@ 2015-05-05 13:37         ` Stéphane ANCELOT
  2015-05-05 17:21           ` Gilles Chanteperdrix
  2015-05-06  8:56           ` Philippe Gerum
  0 siblings, 2 replies; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-05-05 13:37 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

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



On 30/04/2015 14:30, Stéphane ANCELOT wrote:
> On 30/04/2015 10:34, Philippe Gerum wrote:
>> On 04/30/2015 09:08 AM, Stéphane ANCELOT wrote:
>>> 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.
>>> 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
>>
>>> Regards,
>>> S.Ancelot
>>>
>>>
>>>
>>> On 28/04/2015 19:25, Philippe Gerum wrote:
>>>> On 04/28/2015 05:50 PM, Stéphane ANCELOT wrote:
>>>>> 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.
>>>>
>>>>> I also noticed I don't have /dev/rtheap node, is it normal.?
>>>>>
>>>> Yes, /dev/rtheap is gone in 3.x.
>>>>
>>>
>>
>
>
> _______________________________________________
> Xenomai mailing list
> Xenomai@xenomai.org
> 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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-05 13:37         ` Stéphane ANCELOT
@ 2015-05-05 17:21           ` Gilles Chanteperdrix
  2015-05-06  8:21             ` Stéphane ANCELOT
  2015-05-06  8:56           ` Philippe Gerum
  1 sibling, 1 reply; 15+ messages in thread
From: Gilles Chanteperdrix @ 2015-05-05 17:21 UTC (permalink / raw)
  To: Stéphane ANCELOT; +Cc: xenomai

On Tue, May 05, 2015 at 03:37:40PM +0200, Stéphane ANCELOT wrote:
> 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?

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-05 17:21           ` Gilles Chanteperdrix
@ 2015-05-06  8:21             ` Stéphane ANCELOT
  2015-05-06  8:23               ` Gilles Chanteperdrix
                                 ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-05-06  8:21 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

On 05/05/2015 19:21, Gilles Chanteperdrix wrote:
> On Tue, May 05, 2015 at 03:37:40PM +0200, Stéphane ANCELOT wrote:
>> 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?
>
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);
}




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-06  8:21             ` Stéphane ANCELOT
@ 2015-05-06  8:23               ` Gilles Chanteperdrix
  2015-05-06  8:26               ` Gilles Chanteperdrix
  2015-05-06  9:14               ` Philippe Gerum
  2 siblings, 0 replies; 15+ messages in thread
From: Gilles Chanteperdrix @ 2015-05-06  8:23 UTC (permalink / raw)
  To: Stéphane ANCELOT; +Cc: xenomai

On Wed, May 06, 2015 at 10:21:18AM +0200, Stéphane ANCELOT wrote:
> On 05/05/2015 19:21, Gilles Chanteperdrix wrote:
> >On Tue, May 05, 2015 at 03:37:40PM +0200, Stéphane ANCELOT wrote:
> >>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?
> >
> 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.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-06  8:21             ` Stéphane ANCELOT
  2015-05-06  8:23               ` Gilles Chanteperdrix
@ 2015-05-06  8:26               ` Gilles Chanteperdrix
  2015-05-06  8:31                 ` Stéphane ANCELOT
  2015-05-06  9:14               ` Philippe Gerum
  2 siblings, 1 reply; 15+ messages in thread
From: Gilles Chanteperdrix @ 2015-05-06  8:26 UTC (permalink / raw)
  To: Stéphane ANCELOT; +Cc: xenomai

On Wed, May 06, 2015 at 10:21:18AM +0200, Stéphane ANCELOT wrote:
>     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.


>     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 ?

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

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-06  8:26               ` Gilles Chanteperdrix
@ 2015-05-06  8:31                 ` Stéphane ANCELOT
  2015-05-06  8:48                   ` Gilles Chanteperdrix
  0 siblings, 1 reply; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-05-06  8:31 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

On 06/05/2015 10:26, Gilles Chanteperdrix wrote:
> On Wed, May 06, 2015 at 10:21:18AM +0200, Stéphane ANCELOT wrote:
>>      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.
>
>
>>      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 ?
>
>>      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);
}


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-06  8:31                 ` Stéphane ANCELOT
@ 2015-05-06  8:48                   ` Gilles Chanteperdrix
  0 siblings, 0 replies; 15+ messages in thread
From: Gilles Chanteperdrix @ 2015-05-06  8:48 UTC (permalink / raw)
  To: Stéphane ANCELOT; +Cc: xenomai

On Wed, May 06, 2015 at 10:31:22AM +0200, Stéphane ANCELOT wrote:
> On 06/05/2015 10:26, Gilles Chanteperdrix wrote:
> >On Wed, May 06, 2015 at 10:21:18AM +0200, Stéphane ANCELOT wrote:
> >>     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.
> >
> >
> >>     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 ?
> >
> >>     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 :

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.

> 
> 
> 
> 
> 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?

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-05 13:37         ` Stéphane ANCELOT
  2015-05-05 17:21           ` Gilles Chanteperdrix
@ 2015-05-06  8:56           ` Philippe Gerum
  2015-05-06  9:55             ` Stéphane ANCELOT
  1 sibling, 1 reply; 15+ messages in thread
From: Philippe Gerum @ 2015-05-06  8:56 UTC (permalink / raw)
  To: Stéphane ANCELOT, xenomai

On 05/05/2015 03:37 PM, Stéphane ANCELOT wrote:
> 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.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-06  8:21             ` Stéphane ANCELOT
  2015-05-06  8:23               ` Gilles Chanteperdrix
  2015-05-06  8:26               ` Gilles Chanteperdrix
@ 2015-05-06  9:14               ` Philippe Gerum
  2 siblings, 0 replies; 15+ messages in thread
From: Philippe Gerum @ 2015-05-06  9:14 UTC (permalink / raw)
  To: Stéphane ANCELOT, Gilles Chanteperdrix; +Cc: xenomai

On 05/06/2015 10:21 AM, Stéphane ANCELOT wrote:
> On 05/05/2015 19:21, Gilles Chanteperdrix wrote:
>> On Tue, May 05, 2015 at 03:37:40PM +0200, Stéphane ANCELOT wrote:
>>> 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?
>>
> 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.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout
  2015-05-06  8:56           ` Philippe Gerum
@ 2015-05-06  9:55             ` Stéphane ANCELOT
  0 siblings, 0 replies; 15+ messages in thread
From: Stéphane ANCELOT @ 2015-05-06  9:55 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

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


On 06/05/2015 10:56, Philippe Gerum wrote:
> On 05/05/2015 03:37 PM, Stéphane ANCELOT wrote:
>> 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.
>



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-05-06  9:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 15:50 [Xenomai] xenomai 3.0rc4 rt_heap_alloc replies with timeout Stéphane ANCELOT
2015-04-28 17:25 ` Philippe Gerum
2015-04-30  7:08   ` Stéphane ANCELOT
2015-04-30  8:34     ` Philippe Gerum
2015-04-30 12:30       ` Stéphane ANCELOT
2015-05-05 13:37         ` Stéphane ANCELOT
2015-05-05 17:21           ` Gilles Chanteperdrix
2015-05-06  8:21             ` Stéphane ANCELOT
2015-05-06  8:23               ` Gilles Chanteperdrix
2015-05-06  8:26               ` Gilles Chanteperdrix
2015-05-06  8:31                 ` Stéphane ANCELOT
2015-05-06  8:48                   ` Gilles Chanteperdrix
2015-05-06  9:14               ` Philippe Gerum
2015-05-06  8:56           ` Philippe Gerum
2015-05-06  9:55             ` Stéphane ANCELOT

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.