summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Horman <nhorman@openssl.org>2024-03-05 14:22:28 -0500
committerTomas Mraz <tomas@openssl.org>2024-03-22 11:06:59 +0100
commitb50c174ee3b11f916285046d52574ba653745083 (patch)
tree9307663d9ea1c9331d28d4000090d49d5e30b103
parentada9d8c785cce8e75a88675622dd5ec79e9aa6d7 (diff)
Make counters in rcu/rw threads torture test 64 bit
Its possible in some conditions for the rw/rcu torture tests to wrap the counter, leading to false positive failures, make them 64 bits to avoid this Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23724)
-rw-r--r--test/threadstest.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/threadstest.c b/test/threadstest.c
index e0ecfd7814..7bc13fb7a9 100644
--- a/test/threadstest.c
+++ b/test/threadstest.c
@@ -289,8 +289,8 @@ static int reader1_iterations = 0;
static int reader2_iterations = 0;
static int writer1_iterations = 0;
static int writer2_iterations = 0;
-static unsigned int *writer_ptr = NULL;
-static unsigned int global_ctr = 0;
+static uint64_t *writer_ptr = NULL;
+static uint64_t global_ctr = 0;
static int rcu_torture_result = 1;
static void free_old_rcu_data(void *data)
@@ -302,12 +302,12 @@ static void writer_fn(int id, int *iterations)
{
int count;
OSSL_TIME t1, t2;
- unsigned int *old, *new;
+ uint64_t *old, *new;
t1 = ossl_time_now();
for (count = 0; ; count++) {
- new = CRYPTO_zalloc(sizeof(int), NULL, 0);
+ new = CRYPTO_zalloc(sizeof(uint64_t), NULL, 0);
if (contention == 0)
OSSL_sleep(1000);
ossl_rcu_write_lock(rcu_lock);
@@ -351,9 +351,9 @@ static void writer2_fn(void)
static void reader_fn(int *iterations)
{
unsigned int count = 0;
- unsigned int *valp;
- unsigned int val;
- unsigned int oldval = 0;
+ uint64_t *valp;
+ uint64_t val;
+ uint64_t oldval = 0;
int lw1 = 0;
int lw2 = 0;
@@ -365,7 +365,7 @@ static void reader_fn(int *iterations)
valp = ossl_rcu_deref(&writer_ptr);
val = (valp == NULL) ? 0 : *valp;
if (oldval > val) {
- TEST_info("rcu torture value went backwards! (%p) %x : %x\n", (void *)valp, oldval, val);
+ TEST_info("rcu torture value went backwards!");
rcu_torture_result = 0;
}
oldval = val; /* just try to deref the pointer */