#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 directives → Make zero size allocation result consistent across directives |
---|
comment:2 Changed on 04/20/21 at 22:41:58 by Joel Sherrill
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: | assigned → closed |
In d692c62d/rtems:
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.
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