From owner-freebsd-questions@freebsd.org Wed Aug 7 10:52:14 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 8ABDBC6691 for ; Wed, 7 Aug 2019 10:52:14 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from out2-4.antispamcloud.com (out2-4.antispamcloud.com [185.201.17.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 463Sxn4xcHz4YZN; Wed, 7 Aug 2019 10:52:13 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx128.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvIO0-000FX6-Uf; Wed, 07 Aug 2019 11:37:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sumeritec.com; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AEvf/XU3juxJiVkBxNWdmKQSpBjTelO3dEX3J0sE6Js=; b=coGdQwuwvsYehwBK4vsKkdEyvV 8dCQ0p/hWvxpXTwRIRtS166PQ2dgAjcIRIo57F0boz5yQtHFlXNx54WA3HaP4+1jYXALJztLD1tHT GtMhgBoh87uqD+FFC86SAYMXK3FGifjNtRPaC3fDOlqvEqRvWef7B91zt+K1QeLSFphGVV/1OckFY 8O/NTKq/Y+WEBu+ehDCB9KypjOxjeAfQ2dP80MFuHDJqNo705+foB6GYLktXLpt440vbRnQI4zp2/ If5GzjCJHzJAN/WIPvQGswZ4R50AG7Ff5Mz6bHOD6PUJ7lYtvcu18cqz2owwuOXBLiCqEzDJyRqU1 r96cGWSA==; Received: from [114.125.102.203] (port=21615 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hvIN8-00085w-Lr; Wed, 07 Aug 2019 16:36:48 +0700 Date: Wed, 7 Aug 2019 17:36:40 +0800 From: Erich Dollansky To: Konstantin Belousov Cc: Daniel Eischen , freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Subject: Re: mutex held in a thread which is cancelled stays busy Message-ID: <20190807173640.0b2e3aa8.freebsd.ed.lists@sumeritec.com> In-Reply-To: <20190807092035.GG2731@kib.kiev.ua> References: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> <20190807071002.GF2731@kib.kiev.ua> <20190807163757.2b5d52fa.freebsd.ed.lists@sumeritec.com> <20190807092035.GG2731@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=-1.0 X-AuthUser: freebsd.ed.lists@sumeritec.com X-Originating-IP: 153.92.8.106 X-Spampanel-Domain: out.niagahoster.com X-Spampanel-Username: niaga X-Spampanel-Outgoing-Class: unsure X-Spampanel-Outgoing-Evidence: Combined (0.15) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0YiRRkpbHZ8F3zevhEShTfypSDasLI4SayDByyq9LIhVUZbR67CQ7/vm /hHDJU4RXkTNWdUk1Ol2OGx3IfrIJKyP9eGNFz9TW9u+Jt8z2T3KLvPz27Zy3M77yp/kjMbjqZUf pRTVUDoMijXkPdEF/rpQ2ovJBoF8xQkju46r5j99lVo9zfgzQ4Wlm3+W3UHOXwrxwXFyuo2li+Ur O0gJPwhBpc/AiUjjK788fU1YN0ZFlimg/EY5IdMe221qYR+Wtp3/8/wfKPrhhd9E7wPO71GtjG2W GL3bOLqAdXTM05uIzeyh0Jd3oN6q3xRtuJoQG0dJApbAhX/xu5C/RoqqcWS+rDU/p6+dY9OlIYCh R59umdySlZou9qHIGOZDEEo7OwHXl4wgwTqJlTT/fetzilP1n0IyE1Hl7DbyQzX/zn4f268ZzQC7 uo3/eH4wn9OEbAHM+kxWPnVdHuAHFIr8WbVe4NVbVEBU/8Tv9RjL1PyuLyh+nTT5L+X9GNo57sfg Ci+EBctHgf4rD/N3vbhyxAXh0zyP68ySEW4aLV9ERAousBFGkeGUZ3vpwjd8HZATPUKTLGc+44JR fuGjIxKm9mvbib2JMLAaEVsKqNXKjluD1CZXln7VLpZGwtdg3IojlAEMt1kaFoYyeAAUaeLKUwSr B/1sxO/FgfuiyiZJOMFgTem5KIxJG8ba6nOTPDFWMOy22tB7iocLAFHLwsBo/fYr1XkwaCg0lRQN kIB3Rgf9k+1FWQ+vJ8qzoMDtBircbb3h8luEnPBkxuLmymk4TwJYGvU1dZmXYTqG+8bO+MzIpINz P0pcP4SU0rHqL29cUf7QFZeCReDiqGhlxdWfIlX10mLF/SCXnjjc8Lx0r2LvQ8xW9F9VETYLc4wF CxKMgAF3CuiCORZxZEHO4IoGfhWeolXFUIGFpeaHP+y5CgU6waxQivyWPuWbdzF5hFkSzCUKRK6O bnxr/EH5cLWQJzrpAXnrGA4CDNa5JkRTD9kWo0KmXIuc+DfuL+QiSktQyDzmCtL5y7FlMUmBMXtj Ndvy3deP8vNnmz84mDUvZqxn7yCUgX8YuF5WBQr1Bq861xh4MshAphx3J385PE5374TOKCwvBjOt IyvLLUEaS3xI X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463Sxn4xcHz4YZN X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=coGdQwuw; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd.ed.lists@sumeritec.com has no SPF policy when checking 185.201.17.4) smtp.mailfrom=freebsd.ed.lists@sumeritec.com X-Spamd-Result: default: False [5.72 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_XOIP(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[sumeritec.com:+]; NEURAL_HAM_SHORT(-0.17)[-0.170,0]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_LOW(-0.10)[4.17.201.185.list.dnswl.org : 127.0.3.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:49544, ipnet:185.201.17.0/24, country:NL]; IP_SCORE(-0.26)[ip: (0.62), ipnet: 185.201.17.0/24(-1.62), asn: 49544(-0.32), country: NL(0.01)]; RECEIVED_SPAMHAUS_PBL(0.00)[203.102.125.114.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_XBL(5.00)[203.102.125.114.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.4]; R_DKIM_ALLOW(0.00)[sumeritec.com:s=default]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sumeritec.com]; NEURAL_SPAM_MEDIUM(0.18)[0.184,0]; BAD_REP_POLICIES(0.10)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.06)[0.065,0]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; GREYLIST(0.00)[pass,body]; RCVD_TLS_ALL(0.00)[] 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 10:52:14 -0000 Hi, On Wed, 7 Aug 2019 12:20:35 +0300 Konstantin Belousov wrote: > On Wed, Aug 07, 2019 at 04:37:57PM +0800, Erich Dollansky wrote: > > Hi, > > > > On Wed, 7 Aug 2019 10:10:02 +0300 > > Konstantin Belousov wrote: > > > > > On Tue, Aug 06, 2019 at 08:58:30PM -0400, Daniel Eischen wrote: > > > > > > > > > On Aug 6, 2019, at 4:54 AM, Erich Dollansky > > > > > wrote: > > > > > > > > > > Hi, > > > > > > > > > > for testing purpose, I did the following. > > > > > > > > > > Start a thread, initialise a mutex in a global variable, lock > > > > > the mutex and wait in that thread. > > > > > > > > > > Wait in the main program until above's thread waits and > > > > > cancel it. > > > > > > > > > > Clean up behind the cancelled thread but leave intentional the > > > > > mutex locked. > > > > > > > > > > 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_setrobust()? Are you using _lock() or > > > > _trylock()? > > > Robust mutexes only have special properties on the process > > > termination. They behave same as the normal mutexes if the owning > > > thread is terminated. > > > > > man says: > > > > [EOWNERDEAD] The argument mutex points to a robust mutex and the > > previous owning thread terminated while holding the mutex lock. > > So what ? It describes the case when error can be returned, but it is > not required to do so. POSIX wording is the following: > what does POSIX matter when the manual of the operating system the program is running on states something else? Erich