Fix regressions related extent splitting failures.
Fix a fundamental extent_split_wrapper() bug in an error path. Fix extent_recycle() to deregister unsplittable extents before leaking them. Relax xallocx() test assertions so that unsplittable extents don't cause test failures.
This commit is contained in:
parent
9a645c612f
commit
487093d999
@ -441,6 +441,7 @@ extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
|||||||
lead, leadsize, leadsize, size + trailsize, usize +
|
lead, leadsize, leadsize, size + trailsize, usize +
|
||||||
trailsize);
|
trailsize);
|
||||||
if (extent == NULL) {
|
if (extent == NULL) {
|
||||||
|
extent_deregister(tsdn, lead);
|
||||||
extent_leak(tsdn, arena, r_extent_hooks, cache, lead);
|
extent_leak(tsdn, arena, r_extent_hooks, cache, lead);
|
||||||
malloc_mutex_unlock(tsdn, &arena->extents_mtx);
|
malloc_mutex_unlock(tsdn, &arena->extents_mtx);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -454,6 +455,7 @@ extent_recycle(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
|
|||||||
extent_t *trail = extent_split_wrapper(tsdn, arena,
|
extent_t *trail = extent_split_wrapper(tsdn, arena,
|
||||||
r_extent_hooks, extent, size, usize, trailsize, trailsize);
|
r_extent_hooks, extent, size, usize, trailsize, trailsize);
|
||||||
if (trail == NULL) {
|
if (trail == NULL) {
|
||||||
|
extent_deregister(tsdn, extent);
|
||||||
extent_leak(tsdn, arena, r_extent_hooks, cache,
|
extent_leak(tsdn, arena, r_extent_hooks, cache,
|
||||||
extent);
|
extent);
|
||||||
malloc_mutex_unlock(tsdn, &arena->extents_mtx);
|
malloc_mutex_unlock(tsdn, &arena->extents_mtx);
|
||||||
@ -961,7 +963,7 @@ extent_split_wrapper(tsdn_t *tsdn, arena_t *arena,
|
|||||||
|
|
||||||
return (trail);
|
return (trail);
|
||||||
label_error_d:
|
label_error_d:
|
||||||
extent_rtree_release(tsdn, lead_elm_a, lead_elm_b);
|
extent_rtree_release(tsdn, trail_elm_a, trail_elm_b);
|
||||||
label_error_c:
|
label_error_c:
|
||||||
extent_rtree_release(tsdn, lead_elm_a, lead_elm_b);
|
extent_rtree_release(tsdn, lead_elm_a, lead_elm_b);
|
||||||
label_error_b:
|
label_error_b:
|
||||||
|
@ -258,7 +258,7 @@ TEST_BEGIN(test_extra_large)
|
|||||||
"Unexpected xallocx() behavior");
|
"Unexpected xallocx() behavior");
|
||||||
assert_zu_eq(xallocx(p, large2, large3 - large2, flags), large3,
|
assert_zu_eq(xallocx(p, large2, large3 - large2, flags), large3,
|
||||||
"Unexpected xallocx() behavior");
|
"Unexpected xallocx() behavior");
|
||||||
assert_zu_eq(xallocx(p, large1, large2 - large1, flags), large2,
|
assert_zu_ge(xallocx(p, large1, large2 - large1, flags), large2,
|
||||||
"Unexpected xallocx() behavior");
|
"Unexpected xallocx() behavior");
|
||||||
assert_zu_ge(xallocx(p, smallmax, large1 - smallmax, flags), large1,
|
assert_zu_ge(xallocx(p, smallmax, large1 - smallmax, flags), large1,
|
||||||
"Unexpected xallocx() behavior");
|
"Unexpected xallocx() behavior");
|
||||||
@ -357,8 +357,10 @@ test_zero(size_t szmin, size_t szmax)
|
|||||||
|
|
||||||
/* Shrink in place so that we can expect growing in place to succeed. */
|
/* Shrink in place so that we can expect growing in place to succeed. */
|
||||||
sz = szmin;
|
sz = szmin;
|
||||||
assert_zu_eq(xallocx(p, sz, 0, flags), sz,
|
if (xallocx(p, sz, 0, flags) != sz) {
|
||||||
"Unexpected xallocx() error");
|
p = rallocx(p, sz, flags);
|
||||||
|
assert_ptr_not_null(p, "Unexpected rallocx() failure");
|
||||||
|
}
|
||||||
assert_false(validate_fill(p, FILL_BYTE, 0, sz),
|
assert_false(validate_fill(p, FILL_BYTE, 0, sz),
|
||||||
"Memory not filled: sz=%zu", sz);
|
"Memory not filled: sz=%zu", sz);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user