Skip to content

Commit a7fdcc8

Browse files
committed
Fix opt_zero-triggered in-place huge reallocation zeroing.
Fix huge_ralloc_no_move_expand() to update the extent's zeroed attribute based on the intersection of the previous value and that of the newly merged trailing extent.
1 parent c7d5298 commit a7fdcc8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/huge.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,19 @@ huge_ralloc_no_move_expand(tsdn_t *tsdn, void *ptr, size_t oldsize,
262262
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
263263

264264
/*
265-
* Copy zero into is_zeroed_chunk and pass the copy to chunk_alloc(), so
266-
* that it is possible to make correct junk/zero fill decisions below.
265+
* Use is_zeroed_chunk to detect whether the trailing memory is zeroed,
266+
* update extent's zeroed field, and zero as necessary.
267267
*/
268-
is_zeroed_chunk = zero;
269-
268+
is_zeroed_chunk = false;
270269
if (arena_chunk_ralloc_huge_expand(tsdn, arena, ptr, oldsize, usize,
271270
&is_zeroed_chunk))
272271
return (true);
273272

274273
malloc_mutex_lock(tsdn, &arena->huge_mtx);
275-
/* Update the size of the huge allocation. */
276274
huge_node_unset(ptr, node);
277275
extent_node_size_set(node, usize);
276+
extent_node_zeroed_set(node, extent_node_zeroed_get(node) &&
277+
is_zeroed_chunk);
278278
huge_node_reset(tsdn, ptr, node);
279279
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
280280

0 commit comments

Comments
 (0)