Opened 13 years ago
Closed 12 years ago
#395 closed defect (fixed)
memalign() does not work as expected
Reported by: | Vojtech Horky | Owned by: | Jakub Jermář |
---|---|---|---|
Priority: | major | Milestone: | 0.5.0 |
Component: | helenos/lib/c | Version: | mainline |
Keywords: | allocator malloc free memalign | Cc: | |
Blocker for: | Depends on: | ||
See also: |
Description
This problem was discussed on ML (initial post), information here is rather a summary.
In current mainline (1302), memalign()
fails to satisfy a request even when there is evidently enough memory to satisfy it. The attached patch adds a memalign
program to HelenOS that tries to allocate blocks of growing size using malloc()
and memalign()
.
for (i = 0; i < 30; i++) { void *ptr = malloc(1 << i); // or memalign(1 << i, 32) // if ptr != NULL, access it and free it // print i if allocation was successful }
The expected behavior is that both functions would be able to allocate blocks of (more or less) similar sizes. For example, when malloc()
is able to allocate 8M, memalign()
shall be able to allocate at least 4M.
However, as the attached screenshots prove, memalign()
starts to return NULL
much earlier than malloc()
and moreover, this "upper boundary" is not consistent through repeated runs.
It is apparent that this is some problem inside libc memory allocator but the root cause is not known. One possible suspect is rounding/aligning inside allocation routines. The second patch fixes the memalign
application somehow but I am not sure whether it really fixes the root cause and whether the rounding is not an overkill.
Attachments (4)
Change History (6)
by , 13 years ago
Attachment: | test_memalign.patch added |
---|
by , 13 years ago
Attachment: | memalign_good.png added |
---|
Screenshot with "fixed" allocator (i.e. expected behavior)
by , 13 years ago
Attachment: | fix_hint.patch added |
---|
Hint for fixing the memory allocator - reviewer wanted
comment:1 by , 12 years ago
Milestone: | 0.5.0 → 0.5.1 |
---|
No need to have this fixed for 0.5.0, rescheduling for the next release.
comment:2 by , 12 years ago
Milestone: | 0.5.1 → 0.5.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Fixed in mainline,1553.
memalign application demonstrating the problem