From 20e1a94ebac7127a887c9f753187f96834ec24db Mon Sep 17 00:00:00 2001 From: tt2468 Date: Sat, 11 Feb 2023 20:16:43 +0100 Subject: [PATCH] util/threadpool: Initialize worker count to 0 Many platforms (and/or kernels) don't zero memory before it is acquired, resulting in uninitialized memory being used to store critical content. This made the threadpool assume it had an infinite number of threads to work with, despite actually having spawned none. Fixes #1017 --- source/util/util-threadpool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/util/util-threadpool.cpp b/source/util/util-threadpool.cpp index cb67add..0b7a492 100644 --- a/source/util/util-threadpool.cpp +++ b/source/util/util-threadpool.cpp @@ -1,4 +1,5 @@ // Copyright (C) 2020-2022 Michael Fabian Dirks +// Copyright (C) 2023 tt2468 // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -133,7 +134,7 @@ streamfx::util::threadpool::threadpool::~threadpool() } streamfx::util::threadpool::threadpool::threadpool(size_t minimum, size_t maximum) - : _limits{minimum, maximum}, _workers_lock(), _workers(), _tasks_lock(), _tasks_cv(), _tasks() + : _limits{minimum, maximum}, _workers_lock(), _worker_count(0), _workers(), _tasks_lock(), _tasks_cv(), _tasks() { // Spawn the minimum number of threads. spawn(_limits.first);