Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#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)

posix_memalign_test.c (1.1 KB ) - added by dmik 14 years ago.

Download all attachments as: .zip

Change History (8)

by dmik, 14 years ago

Attachment: posix_memalign_test.c added

comment:1 by dmik, 14 years ago

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:2 by bird, 14 years ago

Milestone: libc-0.6.4

comment:3 by bird, 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 bird, 14 years ago

(In [3719]) posix_memalign: Fixed problem with large alignment values. References #223.

comment:5 by bird, 14 years ago

Resolution: fixed
Status: newclosed

(In [3720]) 0.6: Backported r3719: posix_memalign: Fixed problem with large alignment values. Fixes #223.

comment:6 by bird, 14 years ago

(In [3721]) posix_memalign.c: Always set errno. References #223.

comment:7 by bird, 14 years ago

(In [3722]) 0.6: Backported r3721: posix_memalign.c: Always set errno. References #223.

Note: See TracTickets for help on using tickets.