Skip to contentSkip to conversation

rt-tests: pi_stress: Move unlock into if block with matching lock

PATCH In review John B. Wyatt IV 2 participants 2 messages Sep 23, 2024 – Sep 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt-tests: pi_stress: Move unlock into if block with matching lock

Resolve unlocking a not locked mutex.

Issue reported by Valgrind's Helgrind tool.

---
 src/pi_tests/pi_stress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/pi_tests/pi_stress.c +1 -1
index 673a7bb..371e906 100644
@@ -552,8 +552,8 @@ void *reporter(void *arg __attribute__ ((unused)))
 				printf("Current Inversions: %lu\n",
 						total_inversions());
 			}
+			pthread_mutex_unlock(&shutdown_mtx);
 		}
-		pthread_mutex_unlock(&shutdown_mtx);
 
 		/* if we specified a duration, see if it has expired */
 		if (end && time(NULL) > end) {
Signature · 1 line
2.46.0
#1 lore raw
Quoted 29 lines · John B. Wyatt IV

Resolve unlocking a not locked mutex.

Issue reported by Valgrind's Helgrind tool.

---
 src/pi_tests/pi_stress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/pi_tests/pi_stress.c +1 -1
index 673a7bb..371e906 100644
@@ -552,8 +552,8 @@ void *reporter(void *arg __attribute__ ((unused)))
 				printf("Current Inversions: %lu\n",
 						total_inversions());
 			}
+			pthread_mutex_unlock(&shutdown_mtx);
 		}
-		pthread_mutex_unlock(&shutdown_mtx);
 
 		/* if we specified a duration, see if it has expired */
 		if (end && time(NULL) > end) {
Signature · 1 line
2.46.0