Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#4390 closed enhancement (fixed)

Make zero size allocation result consistent across directives

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 6.1
Component: admin Version: 6
Severity: normal Keywords: qualification
Cc: Blocked By:
Blocking:

Description

There is a special case in malloc() which results in a malloc( 0 ) == NULL invariant. This special case should move to rtems_heap_allocate_aligned_with_boundary() to have a consistent behaviour across the API level memory allocation directives.

Change History (7)

comment:1 Changed on 04/20/21 at 18:37:24 by Sebastian Huber

Summary: Make zero size allocation result consistent accross directivesMake zero size allocation result consistent across directives

comment:2 Changed on 04/20/21 at 22:41:58 by Joel Sherrill

This is an area of undefined behavior per POSIX. It might be worth considering having this be a debug failure.

https://pubs.opengroup.org/onlinepubs/009695399/functions/malloc.html

comment:3 Changed on 04/21/21 at 04:43:41 by Sebastian Huber

It is not undefined behaviour in the latest POSIX edition:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html

It is implementation-defined behaviour. The implementation has two options. The RTEMS malloc( 0 ) returns NULL. Linux seems to return a unique pointer.

The rtems_memalign(&p, 8, 0) returns a unique pointer. I think this size == 0 behaviour should be consistent in RTEMS.

comment:4 Changed on 05/04/21 at 11:08:10 by Sebastian Huber <sebastian.huber@…>

Resolution: fixed
Status: assignedclosed

In [changeset:"d692c62dfbf834c16ef7f171ea3161b3f3fac06b/rtems" d692c62d/rtems]:

Error: Processor CommitTicketReference failed
/data/trac/repo/rtems.git does not appear to be a Git repository.

comment:5 Changed on 05/06/21 at 13:15:09 by Sebastian Huber <sebastian.huber@…>

In [changeset:"2c5199bb049efe8e29cd12461dc57bd6e30388e8/rtems" 2c5199b/rtems]:

Error: Processor CommitTicketReference failed
/data/trac/repo/rtems.git does not appear to be a Git repository.

comment:6 Changed on 05/07/21 at 05:08:44 by Sebastian Huber <sebastian.huber@…>

In [changeset:"c46d125569a215226602a7d4b9c346ee074fe365/rtems" c46d125/rtems]:

Error: Processor CommitTicketReference failed
/data/trac/repo/rtems.git does not appear to be a Git repository.

comment:7 Changed on 06/23/21 at 07:07:55 by Sebastian Huber

Keywords: qualification added
Note: See TracTickets for help on using tickets.