From owner-freebsd-threads@freebsd.org Wed Aug 7 04:09:15 2019 Return-Path: Delivered-To: freebsd-threads@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 0205CBD3B2 for ; Wed, 7 Aug 2019 04:09:15 +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 463J0n49Vmz4BZJ for ; Wed, 7 Aug 2019 04:09:13 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx147.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvDG0-00057r-7I for freebsd-threads@freebsd.org; Wed, 07 Aug 2019 06:09:10 +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=fYqwsZPpyPP4AfN8jQUYX4CMnyMPedGSI6FClulRStU=; b=SlYUWZDZyM5EuACcgHzOAOA8Ra 3nUdj9gPDJvQesW8zJ19xxpqRt9Jt1/EuU44sDr5o3IGvT2OVX+OD7X7uL9Ny4/WTDt84Uo8tv/T8 2KbFW210piKTOBzJSHSUmGBqNHJVBLoHr5NO1JPX8fsIUm9efPbB+uw4MqRKg6xXAEjJMFbmMkSvl AuyLwJpk88RSaw1jR6DMR+2IW/GlGTd397/nRyaiqVxHui0iX7QY2ZdTorIfukopUaKy441STQUbL C2IVaJF/v8tG+2XNq+XI0Fok2AtZLeSmVqDJcFD4Wifk9qfKSf1sppRXmdEyhpj9b7s+H4OLI54jG gkB3dXfA==; Received: from [114.125.102.23] (port=15116 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hvDEd-00049Q-Ke; Wed, 07 Aug 2019 11:07:41 +0700 Date: Wed, 7 Aug 2019 12:07:34 +0800 From: Erich Dollansky To: Daniel Eischen Cc: freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Subject: Re: mutex held in a thread which is cancelled stays busy Message-ID: <20190807120734.1c55392d.freebsd.ed.lists@sumeritec.com> In-Reply-To: <0CEB9578-74BE-42E7-A612-9A7AE3DBD052@freebsd.org> References: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> <20190807095521.23e79874.freebsd.ed.lists@sumeritec.com> <0CEB9578-74BE-42E7-A612-9A7AE3DBD052@freebsd.org> 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.11) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0YiRRkpbHZ8F3zevhEShTfypSDasLI4SayDByyq9LIhV4UsW/Vlvetcm 0SuxVQ1snUTNWdUk1Ol2OGx3IfrIJKywOmJyM1qr8uRnWBrbSAGDfcKM/QcQW5M3f6M90DU6mLNt WyfKuzLBS5jlSy+O1N0BcORxfCojcTOpEjtvWHp2U3RPoyZo/FX0u+rlqVSlPDg9YkzbMy6DOYhG 3MUcvhoC5E0fa4xMuNxWhNGpgfrZzHsFnNV2ytQnVONhlZaGFBQA8Ado50lIXu9sNo8pO8kNcJBl FUe4YrZXwJ0S+2TjVgW9/bktU41htiJ8fk7NkDAVHjYntR9elzPavaRCwERBjtYFPuVXfsT0ihIB NX8lghGR310uTa9T9T94Qx6UuKB7SU5M7j/zBp6iK1Co5/LyvYF41YKwtUHAIHcwkMwUd8hF8H+X RkeFFoCQxNYyp7turLxlLrVurcLqU0q1kASi6hr1FOEGhgodHuT0F3kfSxjK/EpQH87O+fXsIADf 6/e92HUiJHLkzIMeCG+jIafPY7UumbsOejcyeB6AGynhLYxG0axR7xEpzKsyxrpVaLTlo0e71UIn awUsVFFOlV/74O4hBSz/kkmPgL+fgIguyyhiVvToNUMJxjOUO/D1aI/Ux94HFRTAE7pjevzazDSm IjYJPO1o8qjYUFRJghlK8kCSsWqOezZWLsxQYz5/Fg2ZsrNMDczDrWg7XwaykpjQC3Hy7EnQ0I8d 2CUPcI6Z84hQe5wfXWyF4q4ddkkBghiXYpmGRqLoqCVipDGlRxrKN754ptIcywXSXIeSueMkipqu MTaEbVQgH501Tli3ghxwEiTVJqDh0qKoKsXx5lllsHqvzpAVkfQrODATkt392PbKVQsIdjJYwcrD UB168S8z47Hpv+aDT5T98FLxi3lUuaf0T6HSYd5otAWSzJS5DU6PNRkfow1xbM/2UJ2204s78JWb K25bRomaFIfnPuaRVYKU9W9tbmVXJBqdHHDmtl4ZBm5rFDTzZHq3tVoXjaawpbTOWP6pIoPAes8r 4Enac/DCt2EvhPPr+/LvXBUj X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463J0n49Vmz4BZJ X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=SlYUWZDZ; 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 [-2.78 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[sumeritec.com:s=default]; HAS_XOIP(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-0.997,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sumeritec.com]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[sumeritec.com:+]; NEURAL_HAM_SHORT(-0.95)[-0.953,0]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; 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]; RCVD_TLS_ALL(0.00)[]; IP_SCORE(-0.43)[ipnet: 185.201.17.0/24(-1.81), asn: 49544(-0.33), country: NL(0.01)]; RECEIVED_SPAMHAUS_PBL(0.00)[23.102.125.114.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11] X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2019 04:09:15 -0000 Hi, On Tue, 6 Aug 2019 23:38:51 -0400 Daniel Eischen wrote: > > On Aug 6, 2019, at 9:55 PM, Erich Dollansky > > wrote: > > > > Hi, > > > > On Tue, 6 Aug 2019 20:58:30 -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()? > >> > >> For _trylock(), you only get EOWNERDEAD for robust mutexes. It > >> seems that you should get EOWNERDEAD for _lock() in this case, so > >> if that's what you're doing, it sounds like it might be a bug. > >> > > I did both. One time with initialising the mutex with its defaults > > by handing over NULL as the attribute setting and one time with the > > attributes set. > > > > I use this line to set the attribute: > > > > pres = pthread_mutexattr_setrobust (& Attr, PTHREAD_MUTEX_ROBUST); > > > > The following line: > > > > pthread_mutexattr_getrobust (& Attr, &pres); > > > > Sets pres also to 1. > > > > I am doing this on 12.0-STABLE FreeBSD 12.0-STABLE r350391 GENERIC > > amd64 with the systems standard compiler. > > > > Is this the corrent way of doing it? > > Yes, I believe so. I'm curious if the bug also exists in -current. > I do not have CURRENT on any machine at the moment. Erich