]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix logic errors in torture_rw_high/low test
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Tue, 16 Sep 2025 15:18:33 +0000 (17:18 +0200)
committerNeil Horman <nhorman@openssl.org>
Wed, 17 Sep 2025 20:24:26 +0000 (16:24 -0400)
"old" was never assigned anything and the first
assignment to "*iterations" in the loop was superfluous.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28574)

(cherry picked from commit a1f6bbf6b0eb5bd15569b225bb0bd443fa879c9c)

test/threadstest.c

index ac12b4c8648a9b6f05042819a15e21e232bdf30f..08d820490cb5c3f19bd646a86dc32e2b2296305f 100644 (file)
@@ -183,13 +183,16 @@ static void rwreader_fn(int *iterations)
         CRYPTO_atomic_add(&rwwriter2_done, 0, &lw2, atomiclock);
 
         count++;
-        if (rwwriter_ptr != NULL && old > *rwwriter_ptr) {
-            TEST_info("rwwriter pointer went backwards\n");
-            rw_torture_result = 0;
+        if (rwwriter_ptr != NULL) {
+            if (old > *rwwriter_ptr) {
+                TEST_info("rwwriter pointer went backwards! %d : %d\n",
+                          old, *rwwriter_ptr);
+                rw_torture_result = 0;
+            }
+            old = *rwwriter_ptr;
         }
         if (CRYPTO_THREAD_unlock(rwtorturelock) == 0)
             abort();
-        *iterations = count;
         if (rw_torture_result == 0) {
             *iterations = count;
             return;