[Bug 237195] pthread_mutex_unlock crash as unlocked mutex destroyed by signaled thread
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Aug 2022 21:34:27 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237195
--- Comment #13 from longwitz@incore.de ---
OK, thank you for clarification. One bug in my test program was by mistake, an
other for demonstration. With following patch the program works as I have
intended:
--- mypshared.c.orig 2022-08-06 21:13:03.438699000 +0200
+++ mypshared.c 2022-08-08 10:24:26.021928000 +0200
@@ -34,7 +34,7 @@
pthread_mutexattr_t attr, *attrp = NULL;
int rc, first, mycounter;
-int init_only_on_first = 0, always_destroy = 1;
+int init_only_on_first = 0, always_destroy = 0;
pthread_mutex_t magic, *magicp = &magic;
@@ -120,7 +120,7 @@
void
start_mutex() {
- if ( init_only_on_first && first ) {
+ if( !init_only_on_first || first ) {
rc = pthread_mutex_init((pthread_mutex_t *)®ionp->mutexp, attrp);
printf("rc of pthread_mutex_init = %d\n", rc);
if( rc ) exit( rc );
--
You are receiving this mail because:
You are the assignee for the bug.