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);
|
assert(arena != NULL);
|
||||||
|
|
||||||
return extent_alloc_default_impl(tsdn, arena, new_addr, size,
|
return extent_alloc_default_impl(tsdn, arena, new_addr, size,
|
||||||
alignment, zero, commit);
|
ALIGNMENT_CEILING(alignment, PAGE), zero, commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1493,14 +1493,15 @@ extent_alloc_wrapper_hard(tsdn_t *tsdn, arena_t *arena,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void *addr;
|
void *addr;
|
||||||
|
size_t palignment = ALIGNMENT_CEILING(alignment, PAGE);
|
||||||
if (*r_extent_hooks == &extent_hooks_default) {
|
if (*r_extent_hooks == &extent_hooks_default) {
|
||||||
/* Call directly to propagate tsdn. */
|
/* Call directly to propagate tsdn. */
|
||||||
addr = extent_alloc_default_impl(tsdn, arena, new_addr, esize,
|
addr = extent_alloc_default_impl(tsdn, arena, new_addr, esize,
|
||||||
alignment, zero, commit);
|
palignment, zero, commit);
|
||||||
} else {
|
} else {
|
||||||
extent_hook_pre_reentrancy(tsdn, arena);
|
extent_hook_pre_reentrancy(tsdn, arena);
|
||||||
addr = (*r_extent_hooks)->alloc(*r_extent_hooks, new_addr,
|
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);
|
extent_hook_post_reentrancy(tsdn);
|
||||||
}
|
}
|
||||||
if (addr == NULL) {
|
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);
|
cassert(have_dss);
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
assert(alignment > 0);
|
assert(alignment == ALIGNMENT_CEILING(alignment, PAGE));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sbrk() uses a signed increment argument, so take care not to
|
* sbrk() uses a signed increment argument, so take care not to
|
||||||
|
@ -21,8 +21,8 @@ bool opt_retain =
|
|||||||
void *
|
void *
|
||||||
extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero,
|
extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero,
|
||||||
bool *commit) {
|
bool *commit) {
|
||||||
void *ret = pages_map(new_addr, size, ALIGNMENT_CEILING(alignment,
|
assert(alignment == ALIGNMENT_CEILING(alignment, PAGE));
|
||||||
PAGE), commit);
|
void *ret = pages_map(new_addr, size, alignment, commit);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user