diff options
author | Jason Evans <jasone@canonware.com> | 2016-11-11 21:14:29 -0800 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-11-11 22:17:27 -0800 |
commit | 2cdf07aba971d1e21edc203e7d4073b6ce8e72b9 (patch) | |
tree | 6e57f6730dda0157c9970dffe8e145488bb8230a /src | |
parent | e916d55ba10ea940d3c04b1d7ca6319fc0e7ca12 (diff) | |
download | jemalloc-2cdf07aba971d1e21edc203e7d4073b6ce8e72b9.tar.gz |
Fix extent_quantize() to handle greater-than-huge-size extents.
Allocation requests can't directly create extents that exceed
HUGE_MAXCLASS, but extent merging can create them.
This fixes a regression caused by
8a03cf039cd06f9fa6972711195055d865673966 (Implement cache index
randomization for large allocations.) and first released in 4.0.0.
This resolves #497.
Diffstat (limited to 'src')
-rw-r--r-- | src/extent.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/extent.c b/src/extent.c index 9f5146e..828f627 100644 --- a/src/extent.c +++ b/src/extent.c @@ -3,15 +3,29 @@ /******************************************************************************/ +/* + * Round down to the nearest chunk size that can actually be requested during + * normal huge allocation. + */ JEMALLOC_INLINE_C size_t extent_quantize(size_t size) { + size_t ret; + szind_t ind; - /* - * Round down to the nearest chunk size that can actually be requested - * during normal huge allocation. - */ - return (index2size(size2index(size + 1) - 1)); + assert(size > 0); + + ind = size2index(size + 1); + if (ind == NSIZES) { + /* + * Allocation requests can't directly create extents that exceed + * HUGE_MAXCLASS, but extent merging can create them. + */ + return (HUGE_MAXCLASS); + } + ret = index2size(ind - 1); + assert(ret <= size); + return (ret); } JEMALLOC_INLINE_C int |