openssl: Intermittent failure of rcu test in test_threads on linux-ppc64le

We can see this failure here: https://github.com/openssl/openssl/actions/runs/12682940557/job/35349171521

However sometimes the test passes.

90-test_threads.t ....................... 
    # INFO:  @ test/threadstest.c:442
    # Staring rcu torture
    # INFO:  @ test/threadstest.c:398
    # Starting reader 1INFO:  @ test/threadstest.c:360
    # Starting writer2
    # 
    # INFO:  @ test/threadstest.c:404
    # Starting reader 2
    # INFO:  @ test/threadstest.c:351
    # Starting writer1
    # INFO:  @ test/threadstest.c:383
    # rcu torture value went backwards! 243373 : 0
    # INFO:  @ test/threadstest.c:457
    # rcu_torture_result is 0
    # 
    # INFO:  @ test/threadstest.c:458
    # performed 3689314 reads and 4949676 writes over 2 read and 2 write threads in 3.997268e+00 seconds
    # INFO:  @ test/threadstest.c:468
    # Average read time 1.083472e-06/read
    # INFO:  @ test/threadstest.c:469
    # Average write time 8.075817e-07/write
    # ERROR: (int) 'rcu_torture_result == 1' failed @ test/threadstest.c:471
    # [0] compared to [1]
    # ERROR: (int) 'rcu_torture_result == 1' failed @ test/threadstest.c:478
    # [0] compared to [1]
    # OPENSSL_TEST_RAND_SEED=1736392675
    not ok 6 - torture_rcu_high

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (28 by maintainers)

Commits related to this issue

Most upvoted comments

That’s unfortunate… May I suggest to add this to your test loop:

--- a/crypto/threads_pthread.c
+++ b/crypto/threads_pthread.c
@@ -503,7 +503,7 @@ void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock)
             if (data->thread_qps[i].depth == 0) {
                 ret = ATOMIC_SUB_FETCH(&data->thread_qps[i].qp->users,
                                        VAL_READER, __ATOMIC_RELEASE);
-                OPENSSL_assert(ret != UINT64_MAX);
+                OPENSSL_assert(READER_COUNT(ret) != READER_MASK);
                 data->thread_qps[i].qp = NULL;
                 data->thread_qps[i].lock = NULL;
             }

just to make sure to catch any underflow on the count, as IMHO currently the assertion would not work when the ID_VAL happens to be non-zero?

I think I see the problem. It has to do with the number of quiescent points (qp’s) we allocate for an rcu lock. Generally speaking we only have 2 and we toggle between them. However, it may occur, due to thread timing, that multiple qp’s get retired and reused before a write side acquires one, leading to an aliasing issue that results in us finishing synchronization operations too early. Working on a fix now.

@nhorman could you please look at this?