Re: wkspace failed allocations with heap protection enabled

2022-04-13 Thread Joel Sherrill
On Wed, Apr 13, 2022 at 10:51 AM Matthew J Fletcher 
wrote:

> Hi Joel,
>
> Works fine without debug, its the deferred free doing _Heap_Allocate with
> the negative size thats causing it.
>

Glad that workaround gets you by it. Please do file a ticket though. :)

--joel

>
>
> On Wed, 13 Apr 2022 at 16:09, Joel Sherrill  wrote:
>
>> This appears to be a bad side-effect of the way the deferred free is
>> implemented
>> when the memory protection/fence is enabled. This is turned on by
>> enabling
>> rtems debug.
>>
>> I'd recommend filing a ticket and assigning it to Sebastian for a real
>> fix.
>>
>> In the meantime, see if building RTEMS without debug enabled helps.
>>
>> --joel
>>
>> On Wed, Apr 13, 2022 at 4:30 AM Matthew J Fletcher 
>> wrote:
>>
>>> Hi,
>>>
>>> Investigating the "Total number of failed allocations:" from the
>>> wkspace cmd i see that;
>>>
>>> /* Statistics */
>>> ++stats->failed_allocs;
>>>
>>> Are incremented when _Heap_Allocate_aligned_with_boundary fails, however
>>> it
>>> seems this will routinely fail due to;
>>>
>>> _Heap_Protection_free_all_delayed_blocks seemingly on purpose creating an
>>> impossibly large allocation.
>>>
>>> uintptr_t large = 0
>>>   - (uintptr_t) HEAP_BLOCK_HEADER_SIZE
>>>   - (uintptr_t) HEAP_ALLOC_BONUS
>>>   - (uintptr_t) 1;
>>>
>>> void *p = _Heap_Allocate( heap, large );
>>>
>>> This makes it difficult to place a breakpoint on failed_allocs to
>>> investigate true low memory situations with heap protection enabled.
>>>
>>>
>>> regards
>>> ---
>>> Matthew J Fletcher
>>> ___
>>> users mailing list
>>> users@rtems.org
>>> http://lists.rtems.org/mailman/listinfo/users
>>>
>>
>
> --
>
> regards
> ---
> Matthew J Fletcher
>
>
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users


Re: wkspace failed allocations with heap protection enabled

2022-04-13 Thread Joel Sherrill
This appears to be a bad side-effect of the way the deferred free is
implemented
when the memory protection/fence is enabled. This is turned on by enabling
rtems debug.

I'd recommend filing a ticket and assigning it to Sebastian for a real fix.

In the meantime, see if building RTEMS without debug enabled helps.

--joel

On Wed, Apr 13, 2022 at 4:30 AM Matthew J Fletcher  wrote:

> Hi,
>
> Investigating the "Total number of failed allocations:" from the
> wkspace cmd i see that;
>
> /* Statistics */
> ++stats->failed_allocs;
>
> Are incremented when _Heap_Allocate_aligned_with_boundary fails, however it
> seems this will routinely fail due to;
>
> _Heap_Protection_free_all_delayed_blocks seemingly on purpose creating an
> impossibly large allocation.
>
> uintptr_t large = 0
>   - (uintptr_t) HEAP_BLOCK_HEADER_SIZE
>   - (uintptr_t) HEAP_ALLOC_BONUS
>   - (uintptr_t) 1;
>
> void *p = _Heap_Allocate( heap, large );
>
> This makes it difficult to place a breakpoint on failed_allocs to
> investigate true low memory situations with heap protection enabled.
>
>
> regards
> ---
> Matthew J Fletcher
> ___
> users mailing list
> users@rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users


Re: get_heap_info memsets stats element

2022-04-13 Thread Joel Sherrill
On Wed, Apr 13, 2022 at 8:32 AM Matthew J Fletcher  wrote:

> Hi,
>
> _Heap_Get_information provides the information but its then memset after
> retrieval, is this a bug or design ?
>
>   _Heap_Get_information(heap, info);
>   memset(>Stats, 0, sizeof(info->Stats));
>

In this case, this call is in support of resource snapshot. This is used in
tests
to ensure the number of objects/allocations is the same before and after a
test case is executed. It verifies no leaks.

The stats section has the number of calls, maximum memory allocated, etc.
and
would legitimately change. By zero'ing it out, it makes it possible to
compare
the before and after versions.

Would be good to have a comment here explaining that. Patch welcome. :_

--joel

>
> --
>
> regards
> ---
> Matthew J Fletcher
> ___
> users mailing list
> users@rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users


get_heap_info memsets stats element

2022-04-13 Thread Matthew J Fletcher
Hi,

_Heap_Get_information provides the information but its then memset after
retrieval, is this a bug or design ?

  _Heap_Get_information(heap, info);
  memset(>Stats, 0, sizeof(info->Stats));

-- 

regards
---
Matthew J Fletcher
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users


wkspace failed allocations with heap protection enabled

2022-04-13 Thread Matthew J Fletcher
Hi,

Investigating the "Total number of failed allocations:" from the
wkspace cmd i see that;

/* Statistics */
++stats->failed_allocs;

Are incremented when _Heap_Allocate_aligned_with_boundary fails, however it
seems this will routinely fail due to;

_Heap_Protection_free_all_delayed_blocks seemingly on purpose creating an
impossibly large allocation.

uintptr_t large = 0
  - (uintptr_t) HEAP_BLOCK_HEADER_SIZE
  - (uintptr_t) HEAP_ALLOC_BONUS
  - (uintptr_t) 1;

void *p = _Heap_Allocate( heap, large );

This makes it difficult to place a breakpoint on failed_allocs to
investigate true low memory situations with heap protection enabled.


regards
---
Matthew J Fletcher
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users