Skip to content

Commit fa09fe7

Browse files
committed
Fix rallocx() sampling code to not eagerly commit sampler update.
rallocx() for an alignment-constrained request may end up with a smaller-than-worst-case size if in-place reallocation succeeds due to serendipitous alignment. In such cases, sampling may not happen.
1 parent 20cd2de commit fa09fe7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/jemalloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
22222222

22232223
prof_active = prof_active_get_unlocked();
22242224
old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr);
2225-
tctx = prof_alloc_prep(tsd, *usize, prof_active, true);
2225+
tctx = prof_alloc_prep(tsd, *usize, prof_active, false);
22262226
if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
22272227
p = irallocx_prof_sample(tsd, old_ptr, old_usize, *usize,
22282228
alignment, zero, tcache, arena, tctx);
@@ -2231,7 +2231,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
22312231
tcache, arena);
22322232
}
22332233
if (unlikely(p == NULL)) {
2234-
prof_alloc_rollback(tsd, tctx, true);
2234+
prof_alloc_rollback(tsd, tctx, false);
22352235
return (NULL);
22362236
}
22372237

@@ -2246,7 +2246,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
22462246
*/
22472247
*usize = isalloc(tsd_tsdn(tsd), p, config_prof);
22482248
}
2249-
prof_realloc(tsd, p, *usize, tctx, prof_active, true, old_ptr,
2249+
prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr,
22502250
old_usize, old_tctx);
22512251

22522252
return (p);

0 commit comments

Comments
 (0)