Subject: Re: Unlocking an unlocked mutex
To: Vincent <10.50@free.fr>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 10/13/2005 09:31:30
--/9DWx/yDrRhgMJTb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 12, 2005 at 11:14:43PM +0200, Vincent wrote:
> Rui Paulo a ??crit :
>=20
> >Unlocking an unlocked mutex is, obviously, not correct :-) The point
> >of that message is to detect mutex problems.
> >You can ignore it by setting the environmental variable
> >PTHREAD_DIAGASSERT to 'A'. See pthread(3) for more info.
>=20
> Yep, that's what I did. But, if I admit gracefully that it is obviously=
=20
> NOT correct, is it, for example, more critical than to free an already=20
> freed chunck of memory? The latter case is, as far as I know, (quite=20
> always) treated as a warning and not as an error???

My day job is writing an application that uses pthreads. These assertions=
=20
REALLY help. The problem with unlocking an unlocked mutex is that you most=
=20
likely just finished modifying data that another thread thought _it_ had=20
exclusive access to. You can end up with problems showing up in whatever=20
code goes to use the unprotected data, so the end error looks like it's=20
miles away from where the bug is.

Take care,

Bill

--/9DWx/yDrRhgMJTb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFDToviWz+3JHUci9cRAlQQAKCWL7SUyJExy6uVRyB+RdNIKYRp9wCggo8l
au5+8F2SVBbFGEnw9oFrOPc=
=rI1g
-----END PGP SIGNATURE-----

--/9DWx/yDrRhgMJTb--