aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-05-17 17:12:13 -0700
committerJason Evans <jasone@canonware.com>2016-06-08 10:10:08 -0700
commita7fdcc8b09d197d64d1772d1e8025add44f48f0a (patch)
tree64ca7d2bc0766f775cf495a9402eec435fdd73f7 /src
parentc7d52980275b22f64c672ebaede28dc95d4f1820 (diff)
downloadjemalloc-a7fdcc8b09d197d64d1772d1e8025add44f48f0a.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/huge.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/huge.c b/src/huge.c
index 1aa02a0..3a2877c 100644
--- a/src/huge.c
+++ b/src/huge.c
@@ -262,19 +262,19 @@ huge_ralloc_no_move_expand(tsdn_t *tsdn, void *ptr, size_t oldsize,
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
/*
- * Copy zero into is_zeroed_chunk and pass the copy to chunk_alloc(), so
- * that it is possible to make correct junk/zero fill decisions below.
+ * Use is_zeroed_chunk to detect whether the trailing memory is zeroed,
+ * update extent's zeroed field, and zero as necessary.
*/
- is_zeroed_chunk = zero;
-
+ is_zeroed_chunk = false;
if (arena_chunk_ralloc_huge_expand(tsdn, arena, ptr, oldsize, usize,
&is_zeroed_chunk))
return (true);
malloc_mutex_lock(tsdn, &arena->huge_mtx);
- /* Update the size of the huge allocation. */
huge_node_unset(ptr, node);
extent_node_size_set(node, usize);
+ extent_node_zeroed_set(node, extent_node_zeroed_get(node) &&
+ is_zeroed_chunk);
huge_node_reset(tsdn, ptr, node);
malloc_mutex_unlock(tsdn, &arena->huge_mtx);