Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Aug 2022 21:34:27 +0000
From:      bugzilla-noreply@freebsd.org
To:        threads@FreeBSD.org
Subject:   [Bug 237195] pthread_mutex_unlock crash as unlocked mutex destroyed by signaled thread
Message-ID:  <bug-237195-13406-bJSLBwiQPi@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-237195-13406@https.bugs.freebsd.org/bugzilla/>
References:  <bug-237195-13406@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D237195

--- 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 =3D NULL;
 int rc, first, mycounter;
-int init_only_on_first =3D 0, always_destroy =3D 1;
+int init_only_on_first =3D 0, always_destroy =3D 0;

 pthread_mutex_t magic, *magicp =3D &magic;

@@ -120,7 +120,7 @@

 void
 start_mutex() {
-   if ( init_only_on_first && first ) {
+   if( !init_only_on_first || first ) {
       rc =3D pthread_mutex_init((pthread_mutex_t *)&regionp->mutexp, attrp=
);
       printf("rc of pthread_mutex_init =3D %d\n", rc);
       if( rc ) exit( rc );

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-237195-13406-bJSLBwiQPi>