mirror of
https://github.com/FEX-Emu/jemalloc.git
synced 2024-11-27 00:50:55 +00:00
Ensure page alignment on extent_alloc.
This is discovered and suggested by @jasone in #1468. When custom extent hooks are in use, we should ensure page alignment on the extent alloc path, instead of relying on the user hooks to do so.
This commit is contained in:
parent
9aab3f2be0
commit
93084cdc89
@ -1256,7 +1256,7 @@ extent_alloc_default(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
|
||||
assert(arena != NULL);
|
||||
|
||||
return extent_alloc_default_impl(tsdn, arena, new_addr, size,
|
||||
alignment, zero, commit);
|
||||
ALIGNMENT_CEILING(alignment, PAGE), zero, commit);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1493,14 +1493,15 @@ extent_alloc_wrapper_hard(tsdn_t *tsdn, arena_t *arena,
|
||||
return NULL;
|
||||
}
|
||||
void *addr;
|
||||
size_t palignment = ALIGNMENT_CEILING(alignment, PAGE);
|
||||
if (*r_extent_hooks == &extent_hooks_default) {
|
||||
/* Call directly to propagate tsdn. */
|
||||
addr = extent_alloc_default_impl(tsdn, arena, new_addr, esize,
|
||||
alignment, zero, commit);
|
||||
palignment, zero, commit);
|
||||
} else {
|
||||
extent_hook_pre_reentrancy(tsdn, arena);
|
||||
addr = (*r_extent_hooks)->alloc(*r_extent_hooks, new_addr,
|
||||
esize, alignment, zero, commit, arena_ind_get(arena));
|
||||
esize, palignment, zero, commit, arena_ind_get(arena));
|
||||
extent_hook_post_reentrancy(tsdn);
|
||||
}
|
||||
if (addr == NULL) {
|
||||
|
@ -113,7 +113,7 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size,
|
||||
|
||||
cassert(have_dss);
|
||||
assert(size > 0);
|
||||
assert(alignment > 0);
|
||||
assert(alignment == ALIGNMENT_CEILING(alignment, PAGE));
|
||||
|
||||
/*
|
||||
* sbrk() uses a signed increment argument, so take care not to
|
||||
|
@ -21,8 +21,8 @@ bool opt_retain =
|
||||
void *
|
||||
extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero,
|
||||
bool *commit) {
|
||||
void *ret = pages_map(new_addr, size, ALIGNMENT_CEILING(alignment,
|
||||
PAGE), commit);
|
||||
assert(alignment == ALIGNMENT_CEILING(alignment, PAGE));
|
||||
void *ret = pages_map(new_addr, size, alignment, commit);
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user