diff options
author | Tomas Mraz <tomas@openssl.org> | 2024-12-11 15:40:40 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-12-13 08:23:21 +0100 |
commit | be4ce01f9f51d4ec64b53626834905a8a1de96ca (patch) | |
tree | fe7dfaead6b5947112dd9b85e752f6f2f27aa3fc /test | |
parent | To verify MAC, we need a MAC (diff) | |
download | openssl-be4ce01f9f51d4ec64b53626834905a8a1de96ca.tar.xz openssl-be4ce01f9f51d4ec64b53626834905a8a1de96ca.zip |
Fix the intermittent lhash_test failure on Windows
We must set pending_delete before the actual deletion as another inserting
or deleting thread can pick up the delete callback before the
ossl_ht_write_unlock() call.
This can happen only if no read locks are pending and only on Windows where
we do not use the write mutex to get the callback list.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26152)
Diffstat (limited to 'test')
-rw-r--r-- | test/lhash_test.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/lhash_test.c b/test/lhash_test.c index 925b84f3cd..aa5504c248 100644 --- a/test/lhash_test.c +++ b/test/lhash_test.c @@ -613,16 +613,24 @@ static void do_mt_hash_work(void) case DO_DELETE: ossl_ht_write_lock(m_ht); expected_rc = expected_m->in_table; + if (expected_rc == 1) { + /* + * We must set pending_delete before the actual deletion + * as another inserting or deleting thread can pick up + * the delete callback before the ossl_ht_write_unlock() call. + * This can happen only if no read locks are pending and + * only on Windows where we do not use the write mutex + * to get the callback list. + */ + expected_m->in_table = 0; + CRYPTO_atomic_add(&expected_m->pending_delete, 1, &ret, worker_lock); + } if (expected_rc != ossl_ht_delete(m_ht, TO_HT_KEY(&key))) { TEST_info("Iteration %d Expected rc %d on delete of element %u which is %s\n", giter, expected_rc, (unsigned int)index, expected_m->in_table ? "in table" : "not in table"); worker_exits[num] = "Failure on delete"; } - if (expected_rc == 1) { - expected_m->in_table = 0; - CRYPTO_atomic_add(&expected_m->pending_delete, 1, &ret, worker_lock); - } ossl_ht_write_unlock(m_ht); if (worker_exits[num] != NULL) return; |