From owner-freebsd-questions@freebsd.org Wed Aug 7 00:58:40 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 38467B8568; Wed, 7 Aug 2019 00:58:40 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.netplex.net", Issuer "RapidSSL RSA CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 463Cmv6Q92z40CN; Wed, 7 Aug 2019 00:58:39 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from [10.166.221.74] (mobile-107-107-57-103.mycingular.net [107.107.57.103]) (authenticated bits=0) by mail.netplex.net (8.15.1/8.15.1/NETPLEX) with ESMTPSA id x770wVaQ016774 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Aug 2019 20:58:32 -0400 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.netplex.net [204.213.176.9]); Tue, 06 Aug 2019 20:58:33 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: mutex held in a thread which is cancelled stays busy From: Daniel Eischen X-Mailer: iPhone Mail (16G77) In-Reply-To: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> Date: Tue, 6 Aug 2019 20:58:30 -0400 Cc: freebsd-threads@freebsd.org, freebsd-questions@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> References: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> To: Erich Dollansky X-Rspamd-Queue-Id: 463Cmv6Q92z40CN X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.78 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.92)[-0.916,0]; NEURAL_HAM_LONG(-0.87)[-0.872,0]; ASN(0.00)[asn:6062, ipnet:204.213.176.0/20, country:US] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2019 00:58:40 -0000 > On Aug 6, 2019, at 4:54 AM, Erich Dollansky wrote: >=20 > Hi, >=20 > for testing purpose, I did the following. >=20 > Start a thread, initialise a mutex in a global variable, lock the mutex > and wait in that thread. >=20 > Wait in the main program until above's thread waits and cancel it. >=20 > Clean up behind the cancelled thread but leave intentional the mutex > locked. >=20 > I would have expected now to get an error like 'EOWNERDEAD' doing > operations with that mutex. But I get 'EBUSY' as the error. Are you initializing the mutex as a robust mutex, via pthread_mutexattr_setr= obust()? Are you using _lock() or _trylock()? For _trylock(), you only get EOWNERDEAD for robust mutexes. It seems that y= ou should get EOWNERDEAD for _lock() in this case, so if that's what you're d= oing, it sounds like it might be a bug. -- DE=