Commit 8dd3089a78 for openssl.org
commit 8dd3089a7883165588d354c157be291d4cec1b93
Author: Jose A. Diaz <josealf@rocketmail.com>
Date: Tue Sep 1 15:49:01 2026 -0500
threads_win: initialise RCU locals not written on every path
The RCU code calls CRYPTO_atomic_load_int() and CRYPTO_atomic_add64()
for their side effect and ignores the return value, in
get_hold_current_qp() and in ossl_rcu_read_unlock(). Those functions
leave the output untouched when they fail, so qp_idx, tmp and ret are
only guaranteed to be written when the call succeeds.
In practice they cannot fail here, because ossl_rcu_lock_new() does not
return a lock unless rw_lock was created. The compiler cannot see that,
though, and reports the reads as potentially uninitialised as soon as
the atomics gain a visible early return - which the next commit adds.
Give the three variables initialisers. Zero is a safe choice in each
case: qp_idx indexes qp_group, which always holds at least two entries,
so both the subscript and the returned pointer stay in bounds; tmp then
matches qp_idx, so the equality test succeeds and the loop exits on its
first pass instead of running again on an indeterminate index; and ret
satisfies the assertion that follows it.
Assisted-by: Claude:claude-opus-5
Reviewed-by: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Merge-date: Thu Sep 24 09:18:02 2026
Merged-from: https://github.com/openssl/openssl/pull/32633
diff --git a/crypto/threads_win.c b/crypto/threads_win.c
index dd1e79d3e9..0788a0483c 100644
--- a/crypto/threads_win.c
+++ b/crypto/threads_win.c
@@ -183,8 +183,8 @@ void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
/* Read side acquisition of the current qp */
static ossl_inline struct rcu_qp *get_hold_current_qp(CRYPTO_RCU_LOCK *lock)
{
- uint32_t qp_idx;
- uint32_t tmp;
+ uint32_t qp_idx = 0;
+ uint32_t tmp = 0;
uint64_t tmp64;
/* get the current qp index */
@@ -273,7 +273,7 @@ void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock)
{
struct rcu_thr_data *data = CRYPTO_THREAD_get_local_ex(CRYPTO_THREAD_LOCAL_RCU_KEY, lock->ctx);
int i;
- LONG64 ret;
+ LONG64 ret = 0;
assert(data != NULL);