#223 closed defect (fixed)
posix_memalign() is broken
Reported by: | dmik | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.4 |
Component: | libc | Version: | 0.6 |
Severity: | normal | Keywords: | |
Cc: |
Description
posix_memalign() does not work as expected. In particular, it is not always able to allocate a block aligned to 256K: it will return -1 in such cases w/o even setting errno to something. The attached example demonstrates this.
Attachments (1)
Change History (8)
by , 14 years ago
Attachment: | posix_memalign_test.c added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Milestone: | → libc-0.6.4 |
---|
comment:3 by , 14 years ago
The problem occurs when there is no suitable block on the heap and a new one is allocated. With a large alignment, there is a fear chance that OS/2 won't give us a lump of memory with the same alignment. Since the _um_heap_expand function doesn't take the alignment into account when expanding the heap for a posix_memalign() call, the following _um_lump_alloc_noexpand call will fail due to misalignment.
comment:4 by , 14 years ago
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note that on my system (eComStation 2.0 Silver Release, libc063) it fails at the very first posix_memalign() call that requests the 256K alignment. Interesting that if you uncomment line #50 in posix_memalign_test() (which asks for some smaller alignments), the first call requesting the 256K alignment will succeed, but the next one will fail.