NetBSD Problem Report #52751
From www@NetBSD.org Wed Nov 22 12:56:00 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C0B267A1B9
for <gnats-bugs@gnats.NetBSD.org>; Wed, 22 Nov 2017 12:55:59 +0000 (UTC)
Message-Id: <20171122125559.16E127A1F8@mollari.NetBSD.org>
Date: Wed, 22 Nov 2017 12:55:59 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: pthread_mutex_lock(3) does not return EINVAL on destroyed lock
X-Send-Pr-Version: www-1.0
>Number: 52751
>Category: lib
>Synopsis: pthread_mutex_lock(3) does not return EINVAL on destroyed lock
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 22 13:00:00 +0000 2017
>Closed-Date: Wed Nov 22 14:00:52 +0000 2017
>Last-Modified: Wed Nov 22 15:50:01 +0000 2017
>Originator: Kamil Rytarowski
>Release: NetBSD 8.99.7 amd64
>Organization:
TNF
>Environment:
NetBSD chieftec 8.99.7 NetBSD 8.99.7 (GENERIC) #8: Tue Nov 21 08:36:07 CET 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
>Description:
pthread_mutex_lock(3) after calling pthread_mutex_destroy(3) does not return EINVAL. It returns errno 0, which is fine.
Linux and FreeBSD return EINVAL and errno 0.
>How-To-Repeat:
$ gcc tt2.c -pthread
$ ./a.out
ret=0 errno=0
$ cat tt2.c
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char *argv[]) {
int ret;
pthread_mutex_t m;
pthread_mutex_init(&m, 0);
pthread_mutex_lock(&m);
pthread_mutex_unlock(&m);
pthread_mutex_destroy(&m);
ret = pthread_mutex_lock(&m);
printf("ret=%d errno=%d\n", ret, errno);
return 0;
}
>Fix:
N/A
>Release-Note:
>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on
destroyed lock
Date: Wed, 22 Nov 2017 14:17:03 +0100
This seems to be undefined behaviour.
From Posix's
pthread_mutex_destroy, pthread_mutex_init - destroy and initialize a mutex
page:
A destroyed mutex object can be reinitialized using
pthread_mutex_init(); the results of otherwise referencing the object
after it has been destroyed are undefined.
and from pthread_mutex_lock:
If mutex does not refer to an initialized mutex object, the
behavior of pthread_mutex_lock(), pthread_mutex_trylock(), and
pthread_mutex_unlock() is undefined.
Martin
From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on
destroyed lock
Date: Wed, 22 Nov 2017 14:58:50 +0100
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--6C3iN6fCuTLN67idkNc7FkOFTt2D8JNGw
Content-Type: multipart/mixed; boundary="1XqGDFsm8GqOiWTG8oNcUosulWFejCEnN";
protected-headers="v1"
From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Message-ID: <c1efc603-e2cd-5d15-a341-9aa82325ab92@gmx.com>
Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on
destroyed lock
References: <pr-lib-52751@gnats.netbsd.org>
<20171122125559.16E127A1F8@mollari.NetBSD.org>
<20171122132001.1F64A7A1F0@mollari.NetBSD.org>
In-Reply-To: <20171122132001.1F64A7A1F0@mollari.NetBSD.org>
--1XqGDFsm8GqOiWTG8oNcUosulWFejCEnN
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
On 22.11.2017 14:20, Martin Husemann wrote:
> The following reply was made to PR lib/52751; it has been noted by GNAT=
S.
>=20
> From: Martin Husemann <martin@duskware.de>
> To: gnats-bugs@NetBSD.org
> Cc:=20
> Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on=
> destroyed lock
> Date: Wed, 22 Nov 2017 14:17:03 +0100
>=20
> This seems to be undefined behaviour.
> From Posix's
> =20
> pthread_mutex_destroy, pthread_mutex_init - destroy and initialize=
a mutex
> =20
> page:
> =20
> A destroyed mutex object can be reinitialized using
> pthread_mutex_init(); the results of otherwise referencing the obj=
ect
> after it has been destroyed are undefined.
> =20
> =20
> and from pthread_mutex_lock:
> =20
> If mutex does not refer to an initialized mutex object, the
> behavior of pthread_mutex_lock(), pthread_mutex_trylock(), and
> pthread_mutex_unlock() is undefined.
> =20
> =20
> Martin
> =20
>=20
Unless someone thinks it's worth to support in libpthread(3), I will
implement proper check on the TSan side. As of now, it's based on the
returned value from the function call.
Therefore, no problem on the NetBSD side.
--1XqGDFsm8GqOiWTG8oNcUosulWFejCEnN--
--6C3iN6fCuTLN67idkNc7FkOFTt2D8JNGw
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJaFYKgAAoJEEuzCOmwLnZsMSsP/iAg6i7Yj/MNPQ7Pk+2AQGxE
EGRas1b2RJz2d7wxGHP4Nx2Nh7H//DnVyxIX3YT90HHD6uGE+XRKsftRVZ1PNLrP
fRrxub3fjaAL7tw+6wbu/s16c200lhgz+uYG5/77OP4QNc/dnD4ibfnVRsY7P3wa
V7pR2nU+r8xpQhrYSsDj6iTR+WbCMIFWQ9PGB52mHLZfNJqGh6qb1sa80jEvZRSQ
ZyX0rb6ZfwMIWlENmYxfmHbTzaUcbnA0W0VMGr6TxbyvXgaET3oGcf1/n9W+04pW
sKJULvyoEcyHFIXBo9HAk9Sm3cTrszOgZdfRV5woB+Dqq1hn9iRLshVz5LyxeDJA
wCyLa/szU00xYwqD/gK5yVPPnfSq64SXTfQ7Ju+Qjh3x44kk4JPqso1q2+Jz+aiX
Y6lLAzqVfVWpTWvvBVzMJHBoh0A+lt0IRHjlVJ+wge9Hqjk0gVae4E82I4T0RBaH
CAj2OuUWjTYDNB4ELFZh6qeL0b3WIrOy7nOQ4NamrobLo3fdyRQcDDwIaq8nXx5M
2x3p5TI5Lx/a+9v5cOhzt/PxkUdfggD0Bnva75rPMCg/ZIGl+19kIhBPUlKgp+iZ
tqwVg/bpzhHQH4oIAca9WoaKY/Y+m8NjzOM2z5ZS8LVQZh88mNIMkMvWsVn707Gd
/+hWN0eNFp2Zo8eU3D62
=qmSr
-----END PGP SIGNATURE-----
--6C3iN6fCuTLN67idkNc7FkOFTt2D8JNGw--
State-Changed-From-To: open->closed
State-Changed-By: kamil@NetBSD.org
State-Changed-When: Wed, 22 Nov 2017 15:00:52 +0100
State-Changed-Why:
Not a NetBSD bug.
Behavior allowed by POSIX.
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on destroyed lock
Date: Wed, 22 Nov 2017 09:17:36 -0500
On Nov 22, 1:00pm, n54@gmx.com (n54@gmx.com) wrote:
-- Subject: lib/52751: pthread_mutex_lock(3) does not return EINVAL on destro
| >Number: 52751
| >Category: lib
| >Synopsis: pthread_mutex_lock(3) does not return EINVAL on destroyed lock
| >Confidential: no
| >Severity: serious
| >Priority: medium
| >Responsible: lib-bug-people
| >State: open
| >Class: sw-bug
| >Submitter-Id: net
| >Arrival-Date: Wed Nov 22 13:00:00 +0000 2017
| >Originator: Kamil Rytarowski
| >Release: NetBSD 8.99.7 amd64
| >Organization:
| TNF
| >Environment:
| NetBSD chieftec 8.99.7 NetBSD 8.99.7 (GENERIC) #8: Tue Nov 21 08:36:07 CET 2017 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64
| >Description:
| pthread_mutex_lock(3) after calling pthread_mutex_destroy(3) does not return EINVAL. It returns errno 0, which is fine.
|
| Linux and FreeBSD return EINVAL and errno 0.
| >How-To-Repeat:
| $ gcc tt2.c -pthread
| $ ./a.out
| ret=0 errno=0
| $ cat tt2.c
| #include <pthread.h>
| #include <stdio.h>
| #include <stdlib.h>
| #include <errno.h>
|
| int main(int argc, char *argv[]) {
| int ret;
|
| pthread_mutex_t m;
| pthread_mutex_init(&m, 0);
| pthread_mutex_lock(&m);
| pthread_mutex_unlock(&m);
| pthread_mutex_destroy(&m);
|
| ret = pthread_mutex_lock(&m);
|
| printf("ret=%d errno=%d\n", ret, errno);
What happens when you set PTHREAD_DIAGASSERT appropriately in the environment?
christos
From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on
destroyed lock
Date: Wed, 22 Nov 2017 16:49:04 +0100
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--WkOWLUlOABH3xfLaCikUQmI012qPPTs9M
Content-Type: multipart/mixed; boundary="DUD5ruXOMkpBWg46i9Bn4XId9LqADDtHi";
protected-headers="v1"
From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Message-ID: <fcc3ddeb-cad4-c226-cade-e4441fff3cc1@gmx.com>
Subject: Re: lib/52751: pthread_mutex_lock(3) does not return EINVAL on
destroyed lock
References: <pr-lib-52751@gnats.netbsd.org>
<20171122125559.16E127A1F8@mollari.NetBSD.org>
<20171122142001.6535E7A1F0@mollari.NetBSD.org>
In-Reply-To: <20171122142001.6535E7A1F0@mollari.NetBSD.org>
--DUD5ruXOMkpBWg46i9Bn4XId9LqADDtHi
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
On 22.11.2017 15:20, Christos Zoulas wrote:
> =20
> What happens when you set PTHREAD_DIAGASSERT appropriately in the envi=
ronment?
$ PTHREAD_DIAGASSERT=3Dae ./a.out
ret=3D0 errno=3D0
--DUD5ruXOMkpBWg46i9Bn4XId9LqADDtHi--
--WkOWLUlOABH3xfLaCikUQmI012qPPTs9M
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJaFZx2AAoJEEuzCOmwLnZs1Z8P/3UEqU2dpfTVau4fPJmNbLY4
AeKVAUpNqpOxEcw6IVSKflPKy7gpbIuP+C7JQbNmpRo//AdE8nFMS7LMYlKdowT8
TNGh5phyDRrtGRwCnaADep4Ypw39Wz7pckpAbVFNfLBUlw+8qggA37msq1L6v5wR
WINT57+K1tXyN7vBCK9xobhCWeYJlwHyEMWAN/MnNaSQxHdMh0kZYeW71TvgVq1J
FnFw6EVTcUvWXIGno/gDpuPHDZLc9dQ2n1eSPueaeTRmPJJL1bhjfkziQ8Ck9X3p
zE0vAqeym5eaHJcN90DmtEWkR0FRcqe2ajQqxtHOZquq/07FH1jtTDTikOR8OAAO
L9aOxfMfHWN+sW9fvyzwY3b40xNqTDvJcYLOecQMTqxrq1LI0n8KPUoHrhRmYEKW
lqWBUUP81tr3WqmhWfjOvuDnUl87nYSTT9hjlV8F/CbxSO+49dp249zfTx6qsh98
hsdlrWdF8v6y7FixV9e7maF8/xkdqMmrL1Rvp8M7EV1y4AitSzjiKiczmECxqd2C
rhJccS6+mf+W52N+shvO1fGEOD033aFK/PBh6XtoXliO6jc8iRwoJ3t2X6DHpZ4v
hfDajik0iYiqEAiMYDII5v0i8ISjBl9EStfZb7UUNIYU353Gj9vmO5oG8X/PaHaq
MZS2OZJ9on0c75mQMgEs
=BQC8
-----END PGP SIGNATURE-----
--WkOWLUlOABH3xfLaCikUQmI012qPPTs9M--
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.