aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2018-02-26 17:11:29 -0800
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2018-02-27 19:43:05 -0800
commit26b1c1398264dec25bf998f6bec21799ad4513da (patch)
tree2f58c87db969a9782bd113335726c82a60baced0 /src
parentdd7e283b6f7f18054af3e14457251757945ab17d (diff)
downloadplatform_external_jemalloc_new-26b1c1398264dec25bf998f6bec21799ad4513da.tar.gz
platform_external_jemalloc_new-26b1c1398264dec25bf998f6bec21799ad4513da.tar.bz2
platform_external_jemalloc_new-26b1c1398264dec25bf998f6bec21799ad4513da.zip
Background threads: fix an indexing bug.
We have a buffer overrun that manifests in the case where arena indices higher than the number of CPUs are accessed before arena indices lower than the number of CPUs. This fixes the bug and adds a test.
Diffstat (limited to 'src')
-rw-r--r--src/background_thread.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/background_thread.c b/src/background_thread.c
index 6baff22b..a8a5a052 100644
--- a/src/background_thread.c
+++ b/src/background_thread.c
@@ -600,7 +600,8 @@ background_threads_enable(tsd_t *tsd) {
arena_get(tsd_tsdn(tsd), i, false) == NULL) {
continue;
}
- background_thread_info_t *info = &background_thread_info[i];
+ background_thread_info_t *info = &background_thread_info[
+ i % ncpus];
malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
assert(info->state == background_thread_stopped);
background_thread_init(tsd, info);