From 31bfb3e7b0c48009c64a1375f6b8e5e7c5a29cdc Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Mon, 31 Jan 2011 19:58:22 -0800 Subject: Fix an alignment-related bug in huge_ralloc(). Fix huge_ralloc() to call huge_palloc() only if alignment requires it. This bug caused under-sized allocation for aligned huge reallocation (via rallocm()) if the requested alignment was less than the chunk size (4 MiB by default). --- jemalloc/src/huge.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jemalloc/src/huge.c b/jemalloc/src/huge.c index 0aadc43..de09198 100644 --- a/jemalloc/src/huge.c +++ b/jemalloc/src/huge.c @@ -83,7 +83,7 @@ huge_palloc(size_t size, size_t alignment, bool zero) * alignment, in order to assure the alignment can be achieved, then * unmap leading and trailing chunks. */ - assert(alignment >= chunksize); + assert(alignment > chunksize); chunk_size = CHUNK_CEILING(size); @@ -192,7 +192,7 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra, * different size class. In that case, fall back to allocating new * space and copying. */ - if (alignment != 0) + if (alignment > chunksize) ret = huge_palloc(size + extra, alignment, zero); else ret = huge_malloc(size + extra, zero); @@ -201,7 +201,7 @@ huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra, if (extra == 0) return (NULL); /* Try again, this time without extra. */ - if (alignment != 0) + if (alignment > chunksize) ret = huge_palloc(size, alignment, zero); else ret = huge_malloc(size, zero); -- cgit v0.12