Ticket #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
Change History
comment:1 Changed 3 years ago by dmik
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.
comment:3 Changed 2 years ago by bird
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.
