From 349d1cfddcfa33d352240582a3803f2eba39d9a0 Mon Sep 17 00:00:00 2001 From: DK Date: Sun, 13 Nov 2016 14:48:15 +0200 Subject: [PATCH] Fixed deadlock in CRYPTO_THREAD_run_once for Windows Fixed deadlock in CRYPTO_THREAD_run_once() if call to init() is causing a recursive call to CRYPTO_THREAD_run_once() again that is causing a hot deadloop inside do { } while (result == ONCE_ININIT); section. CLA: trivial Reviewed-by: Richard Levitte Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/1913) --- crypto/threads_win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/threads_win.c b/crypto/threads_win.c index 4e0de908ee..5347c9e46b 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -78,8 +78,8 @@ int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)) do { result = InterlockedCompareExchange(lock, ONCE_ININIT, ONCE_UNINITED); if (result == ONCE_UNINITED) { - init(); *lock = ONCE_DONE; + init(); return 1; } } while (result == ONCE_ININIT); -- 2.25.1