From owner-freebsd-threads@freebsd.org Sun Aug 4 21:00:54 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 1D171B18C9 for ; Sun, 4 Aug 2019 21:00:54 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 461tbV003Rz3NTN for ; Sun, 4 Aug 2019 21:00:53 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: by mailman.nyi.freebsd.org (Postfix) id F3BFBB18C8; Sun, 4 Aug 2019 21:00:53 +0000 (UTC) Delivered-To: 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 F388CB18C7 for ; Sun, 4 Aug 2019 21:00:53 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 461tbT6BXwz3NTL for ; Sun, 4 Aug 2019 21:00:53 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B636F933F for ; Sun, 4 Aug 2019 21:00:53 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x74L0rch029367 for ; Sun, 4 Aug 2019 21:00:53 GMT (envelope-from bugzilla-noreply@FreeBSD.org) Received: (from bugzilla@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x74L0rR8029360 for threads@FreeBSD.org; Sun, 4 Aug 2019 21:00:53 GMT (envelope-from bugzilla-noreply@FreeBSD.org) Message-Id: <201908042100.x74L0rR8029360@kenobi.freebsd.org> X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@FreeBSD.org using -f From: bugzilla-noreply@FreeBSD.org To: threads@FreeBSD.org Subject: Problem reports for threads@FreeBSD.org that need special attention Date: Sun, 4 Aug 2019 21:00:53 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Sun, 04 Aug 2019 21:00:54 -0000 To view an individual PR, use: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=(Bug Id). The following is a listing of current problems submitted by FreeBSD users, which need special attention. These represent problem reports covering all versions including experimental development code and obsolete releases. Status | Bug Id | Description ------------+-----------+--------------------------------------------------- Open | 237195 | pthread_mutex_unlock crash as unlocked mutex dest 1 problems total for which you should take action. From owner-freebsd-threads@freebsd.org Tue Aug 6 08:55:30 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 06117BCE32; Tue, 6 Aug 2019 08:55:30 +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 462pPW1p9kz3LFs; Tue, 6 Aug 2019 08:55:26 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx61.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1huvFa-0005G8-RA; Tue, 06 Aug 2019 10:55:24 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EwnC35JO4FhhhHW/FzcI6phBcPsbGkG4cAuQaQ3DX4Q=; b=LWne+MBWQUEKiwiq3EzeAo8C6b 37g/yKVMWSu2ssitLXBkjkYoOPz9LbtM/ux1NvnaPqC3mEzekFPMnquyLsRjlUkVdXS7zxaeIQBug fYY0fYYMHMwxVneKTaIWxolyRZlmZfT2bC5c3IRVFwgIleypzuUWQudnLpdr3BJM1U3GQve9NxHCF ZohzUSn6e4/VMECyDeg/QsItOxUMdPqoNx0QKio+AQbDv9ripwurrbsUfdCTln7epGgZPjMvDZGCQ 2WK6bviMKsoFyck48McHPn3ObijQjgAt16eDagLTW+wN5fwuRSLIMSkUY18+3b8zVm1BIYRZxEYkt NlOo1D8w==; Received: from [114.125.104.25] (port=53151 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1huvEk-0008lu-Jf; Tue, 06 Aug 2019 15:54:36 +0700 Date: Tue, 6 Aug 2019 16:54:29 +0800 From: Erich Dollansky To: freebsd-threads@freebsd.org Cc: freebsd-questions@freebsd.org Subject: mutex held in a thread which is cancelled stays busy Message-ID: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> 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+Jt8z2T3Kht+IZhY6ch0O83RbO74UuchG FjsEC1XQn4kD580oZ36VWj3N+DNDhaWbf5bdQc5fT1WcYtDP/4y2NaPLrBX+bUGlz8CJSOMrvzx9 TVg3RkVXXAbgwJTs9OPCd7ZRQeo+p8jZ4AoGBlDR94YkH0RjFQmsAcf1kLoKapRG7lc9JeDN7KHQ l3eg3qrfFG24mhAbgq187NiIKOf+KSg+XppMqz7bfuwlcJJEKTupS5XvURwhEWyJzIkwSFAW0Pw8 uiKeMUJTS2Jsxpkx+IHIsDarm2Hx5e4YMH5a+Vxo+Gz4gw56nrUo2iUXYOUfZrYt2kwya2u/aJSy +XYIL3TVXRgGu+ISfO+8Nwazmqab1cMTal0k88rkq0CsLjZ84JRIA6Ye/ajVf3YKfhRT0knXt1CR LuLMOPhV8sZiFXmtTilamlYRFmMy/B+9uFk6vL63wFNT/iH+i0krVjPg4j89ZZyO7mN7AnWnYo04 a2ey4hx/dv+muc596OjLSvKX9IT2wJHgmTBPB3ojkwVz5nkXGxmpgHMcN6qoXPjenLhIOF1oeRbs um4BtTmK88nRNTFa+st+XaoInkRdNlt33zOhWO9WO54rOm8qiHFF9QDz4mC1Fk6A4C3fxV8V8Cbn AWESwbg6xu2OfQrGyuxJBL08Tx1B6MUXC2YrxA3JqQGzPWUXNAL5luHEIOz7YnQP9uRZXMDdNgA/ bvpxeniqBDKdL+6MGbK4t8eoCcCPuuAofv54KaZJD4BSWMbTv4/F9nZCflAXVKFwDpe+9rZABUSO mrMA1sfhtY1GZZolCkLnLN7c0R+MPCdbWjlZ4FwOnzX+Io4BoxTkj0hGlATQgXlJtJ0i5pE2QAQR POB84MmsDrk3yRlOP34VGRo5L8M2MA2Zvy07rVJth1gDB2lpXMdbvAc7tiERbInMiTBIUBbQ/Dy6 Ip65tyiUWX+tf7ZF5CSWokMB/eSqQACX6tONkFbPlnFTwFrgPv9TQfT8VfEBrwtfkhA= X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 462pPW1p9kz3LFs X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=LWne+MBW; 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 [-1.77 / 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)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[sumeritec.com]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-0.45)[ipnet: 185.201.17.0/24(-1.92), asn: 49544(-0.34), country: NL(0.01)]; DKIM_TRACE(0.00)[sumeritec.com:+]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_SHORT(-0.93)[-0.925,0]; NEURAL_HAM_MEDIUM(-0.99)[-0.993,0]; R_SPF_NA(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[4.17.201.185.list.dnswl.org : 127.0.3.1]; RECEIVED_SPAMHAUS_PBL(0.00)[25.104.125.114.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:49544, ipnet:185.201.17.0/24, country:NL]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[] 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: Tue, 06 Aug 2019 08:55:30 -0000 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. Of course, the program is not able to do any thing with that mutex. Where is the misunderstanding? Erich From owner-freebsd-threads@freebsd.org Wed Aug 7 00:58:40 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 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-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 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= From owner-freebsd-threads@freebsd.org Wed Aug 7 01:56:25 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 C908EBA8A2 for ; Wed, 7 Aug 2019 01:56:25 +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 463F3X5Zyzz440q for ; Wed, 7 Aug 2019 01:56:24 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx120.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvBBa-0012Ab-6f for freebsd-threads@freebsd.org; Wed, 07 Aug 2019 03:56:22 +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=1e78t4imKpgUmFxG2B5GuLtxc9x7+/NJa3kdb6vDPt0=; b=rF7ysYRbs9NaWWAuMIgra2Ruky 2e08kZcEEgBumv7P5guLigAa5fBPCaZPBBblyZUul4iYUy4IQeY765vSoU+kFSSoH1tqat9jxTgO9 TqumBBWORMmPY5SVgnIbxDFyLTSMGOXQ06fqQcdpHprxzhoyY7vTkrAbm41xCX59yI3H2QZBIP8aV vcn73HnbIec5BN0oonJwMKTlyBIWU1XYqFqaXyzNKitqPQiHz6zc3xuKW5guu++rYXLeSH3qLxsrU MyDw/oqxZiEW9viio0pOT/JRIEPV5gGM8pNKidZWvfJW5SAlZ4wnqOMt8k7NkTR9EPDBejsAiBpbB Zgum7jkg==; Received: from [114.125.104.25] (port=40395 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hvBAh-0009xs-F4; Wed, 07 Aug 2019 08:55:29 +0700 Date: Wed, 7 Aug 2019 09:55:21 +0800 From: Erich Dollansky To: Daniel Eischen Cc: freebsd-threads@freebsd.org, freebsd-questions@freebsd.org Subject: Re: mutex held in a thread which is cancelled stays busy Message-ID: <20190807095521.23e79874.freebsd.ed.lists@sumeritec.com> In-Reply-To: <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> References: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> <1FC05CEB-982F-484F-9E41-5A74FF564494@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.10) X-Recommended-Action: accept X-Filter-ID: Mvzo4OR0dZXEDF/gcnlw0YiRRkpbHZ8F3zevhEShTfypSDasLI4SayDByyq9LIhVcXSMTL9HkUMo SGLCNdCGjkTNWdUk1Ol2OGx3IfrIJKywOmJyM1qr8uRnWBrbSAGDfcKM/QcQW5M3f6M90DU6mLNt WyfKuzLBS5jlSy+O1N0BcORxfCojcTOpEjtvWHp2IJb1FKLNsjvUSqjLKZkTrTg9YkzbMy6DOYhG 3MUcvhoC5E0fa4xMuNxWhNGpgfrZzHsFnNV2ytQnVONhlZaGFBQA8Ado50lIXu9sNo8pO8kLVwl4 MD27u7ynKZb4TqTDVgW9/bktU41htiJ8fk7NkDAVHjYntR9elzPavaRCwERBjtYFPuVXfsT0ihIB NX8lghGR310uTa9T9T94Qx6UuKB7SU5M7j/zBp6iK1Co5/LyvYF41YKwtUHAIHcwkMwUd8hF8H+X RkeFFoCQxNYyp7turLxlLrVurcLqU0q1kASi6hr1FOEGhgodHuT0F3kfSxjK/EpQH87O+fXsIADf 6/e92HUiJHLkzIMeCG+jIafPY7UumbsOejcyeB6AGynhLYxG0axR7xEpzKsyxrpVaLTlo0e71UIn awUsVFFOlV/74O4hBSz/kkmPgL+fgIguSMbKk2e9G11Azr3iStcENdj9x4PWT7trWXGgMYrgWnHK axDVS0vdsIXmmT90wb1xwxqeeDDmjLCnpQf6ku5kW1BCtQF/9CBw4y9jfRtIAhTglGrdRgcS3bYi 8gwoFJOVb1gnp9htNUCeH1MEeKnWYzYAP276cXp4qgQynS/ujBk14O9uIBc4R2FHvu2iptL1u3Q2 fQqqrKGeyubQR9K7jU4vidrAbzPztKfs4s5XguKm1K5iNA1wnmU4zGCXxM+PxIb2spKBkQqOaCyT p/d/hHLgPBUCbE0tM1sfNl2t8YqRNkAEETzgfODJrA65N8kZVm2lHuINJIGiJ73RKeuKpVaXv/21 ZIPO13utXt9B17khEWyJzIkwSFAW0Pw8uiKeA9a5xIXWLWP5TEF+bN/aB3VdM9QAgYnxkm3ga//4 ZxQQddh7BR1NngH8ZlFzSe+X X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463F3X5Zyzz440q X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=rF7ysYRb; 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.69 / 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.85)[-0.852,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.44)[ipnet: 185.201.17.0/24(-1.87), asn: 49544(-0.33), country: NL(0.01)]; RECEIVED_SPAMHAUS_PBL(0.00)[25.104.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 01:56:25 -0000 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? Erich From owner-freebsd-threads@freebsd.org Wed Aug 7 03:38:54 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 053B2BCA8F; Wed, 7 Aug 2019 03:38:54 +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 463HKn4t7Gz49Dg; Wed, 7 Aug 2019 03:38:53 +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 x773cpG0048327 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 6 Aug 2019 23:38:52 -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 23:38:52 -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: <20190807095521.23e79874.freebsd.ed.lists@sumeritec.com> Date: Tue, 6 Aug 2019 23:38:51 -0400 Cc: freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <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> To: Erich Dollansky X-Rspamd-Queue-Id: 463HKn4t7Gz49Dg X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.84 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; ASN(0.00)[asn:6062, ipnet:204.213.176.0/20, country:US]; NEURAL_HAM_LONG(-0.87)[-0.872,0] 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 03:38:54 -0000 > On Aug 6, 2019, at 9:55 PM, Erich Dollansky wrote: >=20 > Hi, >=20 > On Tue, 6 Aug 2019 20:58:30 -0400 > Daniel Eischen wrote: >=20 >>> 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. =20 >>=20 >> Are you initializing the mutex as a robust mutex, via >> pthread_mutexattr_setrobust()? Are you using _lock() or _trylock()? >>=20 >> 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. >>=20 > 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. >=20 > I use this line to set the attribute: >=20 > pres =3D pthread_mutexattr_setrobust (& Attr, PTHREAD_MUTEX_ROBUST); >=20 > The following line: >=20 > pthread_mutexattr_getrobust (& Attr, &pres); >=20 > Sets pres also to 1. >=20 > I am doing this on 12.0-STABLE FreeBSD 12.0-STABLE r350391 GENERIC > amd64 with the systems standard compiler. >=20 > Is this the corrent way of doing it? Yes, I believe so. I'm curious if the bug also exists in -current. -- DE= 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 From owner-freebsd-threads@freebsd.org Wed Aug 7 05:06:49 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 9425BBEA40; Wed, 7 Aug 2019 05:06:49 +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 463KHF1sQsz4F0R; Wed, 7 Aug 2019 05:06:49 +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 x7756kmu004959 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Aug 2019 01:06:47 -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]); Wed, 07 Aug 2019 01:06:48 -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: <20190807120734.1c55392d.freebsd.ed.lists@sumeritec.com> Date: Wed, 7 Aug 2019 01:06:46 -0400 Cc: freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <9AA32154-7A31-45E1-A354-3AA6A67D67AD@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> <20190807120734.1c55392d.freebsd.ed.lists@sumeritec.com> To: Erich Dollansky X-Rspamd-Queue-Id: 463KHF1sQsz4F0R X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.75 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.87)[-0.871,0]; NEURAL_HAM_LONG(-0.89)[-0.885,0]; ASN(0.00)[asn:6062, ipnet:204.213.176.0/20, country:US] 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 05:06:49 -0000 > On Aug 7, 2019, at 12:07 AM, Erich Dollansky wrote: >=20 > Hi, >=20 > On Tue, 6 Aug 2019 23:38:51 -0400 > Daniel Eischen wrote: >>=20 >> Yes, I believe so. I'm curious if the bug also exists in -current. >>=20 > I do not have CURRENT on any machine at the moment. I can try it tomorrow. I can come up with my own test for it, but it would b= e easier if you could send me (privately, if you want) the one you've alread= y got. -- DE= From owner-freebsd-threads@freebsd.org Wed Aug 7 07:10:16 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 B1DFDC1178; Wed, 7 Aug 2019 07:10:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 463N1h27Wkz4Kr7; Wed, 7 Aug 2019 07:10:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x777A2bv034602 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 7 Aug 2019 10:10:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x777A2bv034602 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x777A2Gv034600; Wed, 7 Aug 2019 10:10:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 7 Aug 2019 10:10:02 +0300 From: Konstantin Belousov To: Daniel Eischen Cc: Erich Dollansky , freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Subject: Re: mutex held in a thread which is cancelled stays busy Message-ID: <20190807071002.GF2731@kib.kiev.ua> References: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 463N1h27Wkz4Kr7 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.78 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.78)[-0.778,0]; NEURAL_HAM_LONG(-1.00)[-0.997,0]; REPLY(-4.00)[] 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 07:10:16 -0000 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. > 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. > > -- > DE > _______________________________________________ > freebsd-threads@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-threads > To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org" From owner-freebsd-threads@freebsd.org Wed Aug 7 08:59:43 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 2F845C3853 for ; Wed, 7 Aug 2019 08:59:43 +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 463QRy1dg8z4QqS for ; Wed, 7 Aug 2019 08:59:41 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx105.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvHTB-0009fL-TB; Wed, 07 Aug 2019 10:38:57 +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=MyNLUwuXUwg1O3A0QTsEp5Tq9c3uMmnuPbjNhd1XnHU=; b=m7A+IJeui/5QBiIXFEgZBvngSs M0+1zB2z35NIrGvOBIjB+RHb9HjCBS4KTEdV0obPXetNFkgLhtxqZwi6pZ9CEOIWDcJTenenELbXd v55tywR4LlGQp5kcui4owtqRlPgzZwdy3QSNjZTneJxZywy/MKJCEV7iWT+kBd07CSIbi/BfetL3X oU10KclAWj74wDl6ZcTac28KasIzeIMWkkO8Vqt3OhW33Y8nQX7jg7VzXiYTpQgWz15y6Q6eFOZXS GhzoLvetHnraaGAsep7jCOnQwaU9JGm3IX4n9a4IpGP4B4w57iqLKu3vOYLtCj+dVrCHDpdJMw4sW 2R9spPlQ==; Received: from [114.125.102.203] (port=34609 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hvHSJ-0000ac-48; Wed, 07 Aug 2019 15:38:05 +0700 Date: Wed, 7 Aug 2019 16:37:57 +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: <20190807163757.2b5d52fa.freebsd.ed.lists@sumeritec.com> In-Reply-To: <20190807071002.GF2731@kib.kiev.ua> References: <20190806165429.14bc4052.freebsd.ed.lists@sumeritec.com> <1FC05CEB-982F-484F-9E41-5A74FF564494@freebsd.org> <20190807071002.GF2731@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/kjMbjqasI M+1mO5msHT/Uvoc3p2kFmojFvWa/TeBjG1sVcoIhB6Ngrg4QU4EP4UaW8Ajohi0A43f5Lwi6tML4 tOzkTn5xyJjbPiGrtKpcAmsAajDk4eBC5LCsiCgzTQ41RDITRcaJmLckW/2NEJnK92B/nZhnh8XQ FantgME3HcWpAEVnFDpXnW7vq/flvXA178y90tVc1I6YtyjcXUGd/XJjjx7b4n0+BqgXxJAe2jeV 7jOwdNp5C2Uq5s/qJROOPrI8BErpu4AtVoDvzYsrGDq9GaeDw3VouFep1z6MLVFydW53ncPlxpSF tW2+oi0GqiLOQcgE5JjM4tOUot/buc06kwgFL6LLI2ptPx1Qxcwni1QIyPobftl8Awtx4/lo0c+3 bpEG6m7m/WfK2g2dzXfwZ8RxepTBqJNhTlGtKUkrtBWgNdSMuNhZC3X/nGdDKYyg+yCv9TR+UxzL ZWL8hwGBjhqs9qInVbqEDKJELrWN6R3Ahxc26Cg4RsdHIVQulKObuEwgAGmqpEYrIOzzG6Mzdyr/ uhQCSSWTdnI0VYddTQcSc8npcfPN1QSe61G2lAP398QL+GVsQ4WnYcmZ0aj0qPl/uZMLhgfeg7qI /OGW6RghMzg958IFbKKlNc0N5cagQhEVniihuDwEGDcmr6e3OPR6sTg77M0R+x8fsZyY3r6hhtDd uEmQaNsuP6MC13FFFvS+GsJq3htclTpSUVgblZ11huJ7StQmUsLIqmAnEWomUV8ShebT8U8Xw9HT DfreWfMdEG+w4w+UCBj80AzHFeE4XjD8YIRbIyMCDTapG1wv+PkEjlaMIKgdxNnS2I5dkIU7rv9S DguAeTunaCXFDs4WM6T6hgb0dJLNfyKLko5LifnL+9wgoTj4ygNPw1XfNxMQN11Phz3Ne8+Pf6jt WO02wSOXSHf4/MYvYKEiKwpEGJdimYZGouioJWKkMaVHGnBqz7TRiWF91U/smddrJvE= X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463QRy1dg8z4QqS X-Spamd-Bar: +++ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=m7A+IJeu; 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 [3.62 / 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.22)[-0.222,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.41)[ipnet: 185.201.17.0/24(-1.76), asn: 49544(-0.33), 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]; NEURAL_HAM_MEDIUM(-0.91)[-0.914,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-0.73)[-0.732,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sumeritec.com]; BAD_REP_POLICIES(0.10)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; GREYLIST(0.00)[pass,body]; RCVD_TLS_ALL(0.00)[] 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 08:59:43 -0000 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. Erich From owner-freebsd-threads@freebsd.org Wed Aug 7 09:20:43 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 BD3DEC41A8; Wed, 7 Aug 2019 09:20:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 463QwB67PLz4S10; Wed, 7 Aug 2019 09:20:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x779KZSe066777 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 7 Aug 2019 12:20:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x779KZSe066777 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x779KZjh066773; Wed, 7 Aug 2019 12:20:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 7 Aug 2019 12:20:35 +0300 From: Konstantin Belousov To: Erich Dollansky 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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190807163757.2b5d52fa.freebsd.ed.lists@sumeritec.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 463QwB67PLz4S10 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.79 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; IP_SCORE_FREEMAIL(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.79)[-0.788,0]; IP_SCORE(0.00)[ip: (-2.65), ipnet: 2001:470::/32(-4.49), asn: 6939(-2.92), country: US(-0.05)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none] 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 09:20:43 -0000 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: If mutex is a robust mutex and the process containing the owning thread terminated while holding the mutex lock, a call to pthread_mutex_lock() shall return the error value [EOWNERDEAD]. If mutex is a robust mutex and the owning thread terminated while holding the mutex lock, a call to pthread_mutex_lock( ) may return the error value [EOWNERDEAD] even if the process in which the owning thread resides has not terminated. Note the difference between shall and may. We only process robust list on the process termination. If the process is still alive, but the thread terminated, it can only happen because the process code asked for the thread termination explicitly, and then the code should be able to keep its own state. On really fatal conditions, like unhandled signals, kernel terminates the process, not a thread. From owner-freebsd-threads@freebsd.org Wed Aug 7 09:37:01 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 0FDB4C4887 for ; Wed, 7 Aug 2019 09:37:01 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from out1-4.antispamcloud.com (out1-4.antispamcloud.com [185.201.16.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 463RH03Hjdz4T1f for ; Wed, 7 Aug 2019 09:37:00 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx66.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvINI-0000mr-DF for freebsd-threads@freebsd.org; Wed, 07 Aug 2019 11:36:58 +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 /hHDJU4RXkTNWdUk1Ol2OGx3IfrIJKywOmJyM1qr8uRnWBrbSAGDfcKM/QcQW5M3f6M90DU6mLNt WyfKuzLBS5jlSy+O1N0BcORxfCojcTOpEjtvWHp2w8gLm6CQ5MihRhR/i+tT+Tg9YkzbMy6DOYhG 3MUcvhoC5E0fa4xMuNxWhNGpgfrZzHsFnNV2ytQnVONhlZaGFBQA8Ado50lIXu9sNo8pO8leERWx q42+EK1fEsHY2YQekVWClPVvbW5lVyQanRxw5mxGAXTBy8/H3WcrcQT70P4zMI4c8Nq+FQDrJBWU PIDRrmD3l7JkEAadJd6kb1ak/4p4cZXX4YNvBwClFIJz3G8Bi53Psle5cUmOuJZEMw7GmFVVgWdB XKkEH0++/JhR/Qa+FEE+TmTK/6Hl36Y/23+8Ksk+aedMfNWSnJswrtlNnos4kZq0S2saclf7zLxw jrn+5FY8K+oejUVpj+PmS0cY4F0NXB9Km4wOR5Bv5o/gO/4cIzb5jJEvQV07OXTtxij/aVmcqksI mUv5IT5amOIamUdylUIKhf3z2GAHxH7I5YgDZB0sDHhGVOFAqoGrjISf4OKj8FrfRTkbIcpG04oP izUrhZlDlZnpoX96W0O7wxqeeDDmjLCnpQf6ku5kW1BCtQF/9CBw4y9jfRtIAhTglGrdRgcS3bYi 8gwoFJOVb1gnp9htNUCeH1MEeKnWYzYAP276cXp4qgQynS/ujBk14O9uIBc4R2FHvu2iptL1e51Q 0JiVvVbWrd4edpm6l04vidrAbzPztKfs4s5XguKm1K5iNA1wnmU4zGCXxM+PxIb2spKBkQqOaCyT p/d/hHLgPBUCbE0tM1sfNl2t8YqRNkAEETzgfODJrA65N8kZVm2lHuINJIGiJ73RKeuKpVaXv/21 ZIPO13utXt9B17khEWyJzIkwSFAW0Pw8uiKeA9a5xIXWLWP5TEF+bN/aB3VdM9QAgYnxkm3ga//4 ZxQQddh7BR1NngH8ZlFzSe+X X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463RH03Hjdz4T1f 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.16.4) smtp.mailfrom=freebsd.ed.lists@sumeritec.com X-Spamd-Result: default: False [9.59 / 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:+]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_LOW(-0.10)[4.16.201.185.list.dnswl.org : 127.0.3.1]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8972, ipnet:185.201.16.0/24, country:DE]; IP_SCORE(0.78)[ipnet: 185.201.16.0/24(1.71), asn: 8972(2.17), country: DE(-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]; NEURAL_SPAM_SHORT(0.97)[0.972,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sumeritec.com]; NEURAL_SPAM_MEDIUM(0.96)[0.960,0]; BAD_REP_POLICIES(0.10)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(0.98)[0.979,0]; MID_CONTAINS_FROM(1.00)[]; R_SPF_NA(0.00)[]; GREYLIST(0.00)[pass,meta]; RCVD_TLS_ALL(0.00)[] X-Spam: Yes 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 09:37:01 -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 From owner-freebsd-threads@freebsd.org Wed Aug 7 10:07:33 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 9FDDDC56B0; Wed, 7 Aug 2019 10:07:33 +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 463RyF2GQLz4W2D; Wed, 7 Aug 2019 10:07:33 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from [10.0.0.52] (ip-414b102e.ct.fixed.ntplx.com [65.75.16.46]) (authenticated bits=0) by mail.netplex.net (8.15.1/8.15.1/NETPLEX) with ESMTPSA id x77A7PXi011614 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Aug 2019 06:07:26 -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]); Wed, 07 Aug 2019 06:07:26 -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: <20190807092035.GG2731@kib.kiev.ua> Date: Wed, 7 Aug 2019 06:07:25 -0400 Cc: Erich Dollansky , freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: 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> To: Konstantin Belousov X-Rspamd-Queue-Id: 463RyF2GQLz4W2D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.87 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-0.89)[-0.890,0]; NEURAL_HAM_SHORT(-0.99)[-0.986,0]; ASN(0.00)[asn:6062, ipnet:204.213.176.0/20, country:US] 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 10:07:33 -0000 > On Aug 7, 2019, at 5:20 AM, Konstantin Belousov wrot= e: >=20 >> On Wed, Aug 07, 2019 at 04:37:57PM +0800, Erich Dollansky wrote: >> Hi, >>=20 >> On Wed, 7 Aug 2019 10:10:02 +0300 >> Konstantin Belousov wrote: >>=20 >>>> On Tue, Aug 06, 2019 at 08:58:30PM -0400, Daniel Eischen wrote: >>>>=20 >>>>> 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. =20 >>>>=20 >>>> Are you initializing the mutex as a robust mutex, via >>>> pthread_mutexattr_setrobust()? Are you using _lock() or >>>> _trylock()?=20 >>> Robust mutexes only have special properties on the process >>> termination. They behave same as the normal mutexes if the owning >>> thread is terminated. >>>=20 >> man says: >>=20 >> [EOWNERDEAD] The argument mutex points to a robust mutex and the >> previous owning thread terminated while holding the mutex lock. >=20 > So what ? It describes the case when error can be returned, but it is > not required to do so. POSIX wording is the following: >=20 > If mutex is a robust mutex and the process containing the owning thread > terminated while holding the mutex lock, a call to pthread_mutex_lock() > shall return the error value [EOWNERDEAD]. If mutex is a robust mutex > and the owning thread terminated while holding the mutex lock, a call to > pthread_mutex_lock( ) may return the error value [EOWNERDEAD] even if > the process in which the owning thread resides has not terminated. >=20 > Note the difference between shall and may. We only process robust list > on the process termination. If the process is still alive, but the > thread terminated, it can only happen because the process code asked > for the thread termination explicitly, and then the code should be able > to keep its own state. On really fatal conditions, like unhandled > signals, kernel terminates the process, not a thread. But pthread_mutex_lock() should not return EBUSY; that is only for _trylock(= ). It seems to me _lock() should either return EOWNERDEAD or EDEADLK, or it= just blocks indefinitely. Erich, are you getting EBUSY for pthread_mutex_lock() or is that only for pt= hread_mutex_trylock()? -- DE= From owner-freebsd-threads@freebsd.org Wed Aug 7 10:26:07 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 334ADC5BC3; Wed, 7 Aug 2019 10:26:07 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from out1-4.antispamcloud.com (out1-4.antispamcloud.com [185.201.16.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 463SMg0Vylz4Wxp; Wed, 7 Aug 2019 10:26:06 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx105.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvJ8r-0004v1-QK; Wed, 07 Aug 2019 12:26:04 +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=tfRLMrDcuBwcTC9SFSToRZvUgwSzNJdCSI/KFUT5kl8=; b=mBThAOQq45qs0VV7G9STw4+eMS fNDvAgw/GgGUMpE9Lexfx1OvoHO6NsG7HFGTaBEOpRg1BDClRTUCc55azuKMCwahuYE5tiveqIyKh SrBfQXN8uLjKSq3iOd8AhFskQRLYEaHR4dFWfcK7EvBdeyRGtQ5YLXDLnziuAi1M0IgcyILjTDZLo lqX+gMdnw6QA2bFtg4rJllXskFaNkBiYz+HqehDHMjgYMrEcoOZq1dz8fnVK1TzYxXYKtP5yECSCI rHDwNxRKz7QZkT7lpUKyKB+NPObRTWFq2DGahDWoIqYpVDPpfc77VFszLtmCQR4oY7LeB5togd/PT jDW9w8GA==; Received: from [114.125.102.203] (port=18898 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hvJ8g-0000wy-B7; Wed, 07 Aug 2019 17:25:56 +0700 Date: Wed, 7 Aug 2019 18:25:48 +0800 From: Erich Dollansky To: Daniel Eischen Cc: Konstantin Belousov , freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Subject: Re: mutex held in a thread which is cancelled stays busy Message-ID: <20190807182548.1a8e00dd.freebsd.ed.lists@sumeritec.com> In-Reply-To: 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+Jt8z2T3KSZWQ0mYy/5bX2tR2MxjY1H8+ nrJQjYNop1GreY536hkFHlF5sjR4pyrimN8WEzK+lVo9zfgzQ4Wlm3+W3UHOXwrxwXFyuo2li+Ur O0gJPwiG34hmFjpyHQ7zdFs7vhS5FpdKWY4WDTNb/mmSaM4GPufHzJ6mVE7ewsipSVIfs4Zabjyj 3k9kwKzAqKFfV4UrpuYtsVhg3f/l2/mWu1Athhptu6CedWZCBcUv302F5j093s+AnbV2j8Ow/hRj vbRpAPk7YPj0OKe3lzpnlKaR3sSTXH+3izU4BB1VoFVxTkwhEWyJzIkwSFAW0Pw8uiKe7bgNQRm1 OeEwNfs/X7KNpm7JN07EVzkxDwUeUuKljznUAK0QEz1Q7JH7dxrZvW/0mJfHjaTCzOp63BMLs0qd SISbE1l0jCSqwqiEbnL4lT5T25bh8NcJDK50bxVgqERZsnxNd3HGmXwqaXdfIhxtGD/BNM8813zo gpOdGRAGcQuhFJ7oKehaoNVXSqhCqA/e/iH+i0krVjPg4j89ZZyO7hkDJRaaICR2rDamAVeZMV4D 7fKzXHKOS7epLutw5JLMllEIbIkVe06B7dx0jjZzY3McN6qoXPjenLhIOF1oeRbB0q/OPFFQP2A6 EGLaMo/P36WwUlIQ90Mu0vcNHQ67Fu4moKK5thEF3GBtlksvmTvbXxovJEd6WRmONQXAxSHs5oQB 9puMu8tmNfaWmneAreVHDK/d/D3POXDyR0+CAyjE04Qui3pq/43TyI+2Xq3sVLmn9E+h0mHeaLQF ksyUubCmFQOolhlV/ZRA5nHv4OPW7VqBA9oSlBsbfuqhpOn0f0yWjB8eiHqtxayLndn0kW27yM9f 1+Apz1RqILIQtFMEwq5bRwGe7jud07hsv+XycI/FXhRSOmUQhy9SmS81uJzRPA8gEmeeAc/z3AcE lOvzLPPdXnk9dTX03mZY8tOiLbdHLMfIRuttE8nKqCsLgpnckpWaLvahyBjmQxBKOzuWmKu/Exva /4bO4tpXcmDOqDCHuaY1ySl1jqLk9nhzO4M6gaq1aRjXtWVzuqGnWQc= X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463SMg0Vylz4Wxp X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.94 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.945,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-0.997,0] 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 10:26:07 -0000 Hi, On Wed, 7 Aug 2019 06:07:25 -0400 Daniel Eischen wrote: > > On Aug 7, 2019, at 5:20 AM, 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: > > > > If mutex is a robust mutex and the process containing the owning > > thread terminated while holding the mutex lock, a call to > > pthread_mutex_lock() shall return the error value [EOWNERDEAD]. If > > mutex is a robust mutex and the owning thread terminated while > > holding the mutex lock, a call to pthread_mutex_lock( ) may return > > the error value [EOWNERDEAD] even if the process in which the > > owning thread resides has not terminated. > > > > Note the difference between shall and may. We only process robust > > list on the process termination. If the process is still alive, > > but the thread terminated, it can only happen because the process > > code asked for the thread termination explicitly, and then the code > > should be able to keep its own state. On really fatal conditions, > > like unhandled signals, kernel terminates the process, not a > > thread. > > But pthread_mutex_lock() should not return EBUSY; that is only for > _trylock(). It seems to me _lock() should either return EOWNERDEAD > or EDEADLK, or it just blocks indefinitely. > > Erich, are you getting EBUSY for pthread_mutex_lock() or is that only > for pthread_mutex_trylock()? > EBUSY is only returned when I call 'pthread_mutex_trylock'. The other one just hangs. Give me a bit if time and I will send you then a test program which is extracted from my test environment. Not that the error stems from very own test environment. Erich From owner-freebsd-threads@freebsd.org Wed Aug 7 12:51:28 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 C5C5AAA602; Wed, 7 Aug 2019 12:51:28 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from lwfs1-cam.cam.lispworks.com (mail.lispworks.com [46.17.166.21]) by mx1.freebsd.org (Postfix) with ESMTP id 463WbM48LNz3CPx; Wed, 7 Aug 2019 12:51:27 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (higson.cam.lispworks.com [192.168.1.7]) by lwfs1-cam.cam.lispworks.com (8.15.2/8.15.2) with ESMTP id x77CpNis037004; Wed, 7 Aug 2019 13:51:23 +0100 (BST) (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (localhost.localdomain [127.0.0.1]) by higson.cam.lispworks.com (8.14.4) id x77CpMUY024560; Wed, 7 Aug 2019 13:51:22 +0100 Received: (from martin@localhost) by higson.cam.lispworks.com (8.14.4/8.14.4/Submit) id x77CpMfL024556; Wed, 7 Aug 2019 13:51:22 +0100 Date: Wed, 7 Aug 2019 13:51:22 +0100 Message-Id: <201908071251.x77CpMfL024556@higson.cam.lispworks.com> From: Martin Simmons To: Konstantin Belousov CC: freebsd.ed.lists@sumeritec.com, deischen@freebsd.org, freebsd-questions@freebsd.org, freebsd-threads@freebsd.org In-reply-to: <20190807092035.GG2731@kib.kiev.ua> (message from Konstantin Belousov on Wed, 7 Aug 2019 12:20:35 +0300) Subject: Re: mutex held in a thread which is cancelled stays busy 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> X-Rspamd-Queue-Id: 463WbM48LNz3CPx X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of martin@lispworks.com has no SPF policy when checking 46.17.166.21) smtp.mailfrom=martin@lispworks.com X-Spamd-Result: default: False [0.41 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-0.24)[-0.237,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[lispworks.com]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.35)[0.353,0]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.69)[-0.692,0]; RCVD_IN_DNSWL_NONE(0.00)[21.166.17.46.list.dnswl.org : 127.0.10.0]; R_SPF_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:51055, ipnet:46.17.166.0/24, country:GB]; IP_SCORE(-0.02)[country: GB(-0.08)] 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 12:51:28 -0000 >>>>> On Wed, 7 Aug 2019 12:20:35 +0300, Konstantin Belousov said: > DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x779KZSe066777 > > 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: > > If mutex is a robust mutex and the process containing the owning thread > terminated while holding the mutex lock, a call to pthread_mutex_lock() > shall return the error value [EOWNERDEAD]. If mutex is a robust mutex > and the owning thread terminated while holding the mutex lock, a call to > pthread_mutex_lock( ) may return the error value [EOWNERDEAD] even if > the process in which the owning thread resides has not terminated. > > Note the difference between shall and may. That is clear in POSIX, so should the FreeBSD man page be changed to say "process containing the owning thread" at least? Currently the section starts with: The pthread_mutex_lock() function will fail if: and the word "will" reads to me like a "shall", not a "may". Code relies on this interpretation of "will" in other man pages, e.g. for [EWOULDBLOCK] in accept(2). __Martin From owner-freebsd-threads@freebsd.org Wed Aug 7 17:26:34 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 01316B1C1C; Wed, 7 Aug 2019 17:26:34 +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 463dhn4jj4z42yB; Wed, 7 Aug 2019 17:26:33 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from [10.0.0.52] (ip-414b102e.ct.fixed.ntplx.com [65.75.16.46]) (authenticated bits=0) by mail.netplex.net (8.15.1/8.15.1/NETPLEX) with ESMTPSA id x77HQVR7022963 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Aug 2019 13:26:31 -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]); Wed, 07 Aug 2019 13:26:32 -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: <20190807182548.1a8e00dd.freebsd.ed.lists@sumeritec.com> Date: Wed, 7 Aug 2019 13:26:31 -0400 Cc: freebsd-questions@freebsd.org, freebsd-threads@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: 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> <20190807182548.1a8e00dd.freebsd.ed.lists@sumeritec.com> To: Erich Dollansky X-Rspamd-Queue-Id: 463dhn4jj4z42yB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-2.84 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; NEURAL_HAM_LONG(-0.86)[-0.858,0]; ASN(0.00)[asn:6062, ipnet:204.213.176.0/20, country:US] 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 17:26:34 -0000 > On Aug 7, 2019, at 6:25 AM, Erich Dollansky wrote: >=20 > Hi, >=20 > On Wed, 7 Aug 2019 06:07:25 -0400 > Daniel Eischen wrote: >=20 >>> On Aug 7, 2019, at 5:20 AM, Konstantin Belousov >>> wrote:=20 >>>> On Wed, Aug 07, 2019 at 04:37:57PM +0800, Erich Dollansky wrote: >>>> Hi, >>>>=20 >>>> On Wed, 7 Aug 2019 10:10:02 +0300 >>>> Konstantin Belousov wrote: >>>>=20 >>>>>>> On Tue, Aug 06, 2019 at 08:58:30PM -0400, Daniel Eischen wrote: >>>>>>>=20 >>>>>>> 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. =20 >>>>>>=20 >>>>>> Are you initializing the mutex as a robust mutex, via >>>>>> pthread_mutexattr_setrobust()? Are you using _lock() or >>>>>> _trylock()? =20 >>>>> Robust mutexes only have special properties on the process >>>>> termination. They behave same as the normal mutexes if the owning >>>>> thread is terminated. >>>>>=20 >>>> man says: >>>>=20 >>>> [EOWNERDEAD] The argument mutex points to a robust mutex and the >>>> previous owning thread terminated while holding the mutex lock. =20 >>>=20 >>> So what ? It describes the case when error can be returned, but it >>> is not required to do so. POSIX wording is the following: >>>=20 >>> If mutex is a robust mutex and the process containing the owning >>> thread terminated while holding the mutex lock, a call to >>> pthread_mutex_lock() shall return the error value [EOWNERDEAD]. If >>> mutex is a robust mutex and the owning thread terminated while >>> holding the mutex lock, a call to pthread_mutex_lock( ) may return >>> the error value [EOWNERDEAD] even if the process in which the >>> owning thread resides has not terminated. >>>=20 >>> Note the difference between shall and may. We only process robust >>> list on the process termination. If the process is still alive, >>> but the thread terminated, it can only happen because the process >>> code asked for the thread termination explicitly, and then the code >>> should be able to keep its own state. On really fatal conditions, >>> like unhandled signals, kernel terminates the process, not a >>> thread. =20 >>=20 >> But pthread_mutex_lock() should not return EBUSY; that is only for >> _trylock(). It seems to me _lock() should either return EOWNERDEAD >> or EDEADLK, or it just blocks indefinitely. >>=20 >> Erich, are you getting EBUSY for pthread_mutex_lock() or is that only >> for pthread_mutex_trylock()? >>=20 > EBUSY is only returned when I call 'pthread_mutex_trylock'. The other > one just hangs. In this case, I think FreeBSD is behaving correctly. I think perhaps the on= ly problem is that the man page isn't reflecting the POSIX wording. -- DE= From owner-freebsd-threads@freebsd.org Thu Aug 8 06:10:49 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 E0AEBC4488; Thu, 8 Aug 2019 06:10:49 +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 463yfZ4BH8z3P6w; Thu, 8 Aug 2019 06:10:46 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx61.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hvbdJ-0009OD-BC; Thu, 08 Aug 2019 08:10:44 +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=Ti5+zI7Sxs/SH2VswNZtXB4EJcKahAfBaDTv/C+I1F4=; b=cNu2WU4fi508m+NkZHgVrmYnGg TBnKGZWs57hH5eakOMWyTTsO6MvX+cRPlaqKR3hhfpX3ZkTdkWuGM5hw9aE0vhhwSFJjjGAKYO++U tVcOJJl/u3adMUkmZUVxPXwdFVbwIZURYTvLlPYJXmo13smLNe/UmINNZqUQWEMRIE7z5zwXFZWBo Oww2mtVUKz65GFn2U2AfaV/G7uT6OLzg0CbzcQ0M0S/DK1Focc/Tk9NPGgjRW+PxqrzpaOoHnoTvQ rlkIxoqc6XK6UTdQPRiOIWtow690868mpfne8kWM9wLwtR7LbAO4EOoveD9LoEtEBN+HryyND3I1O sAyP4v0w==; Received: from [114.125.119.173] (port=52152 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hvbcS-0003zv-9N; Thu, 08 Aug 2019 13:09:54 +0700 Date: Thu, 8 Aug 2019 14:09:45 +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: <20190808140945.7eb235aa.freebsd.ed.lists@sumeritec.com> In-Reply-To: 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> <20190807182548.1a8e00dd.freebsd.ed.lists@sumeritec.com> 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+Jt8z2T3KvyegFAN3MVG+8Mu8M+ESLE+f zSH/OCabdgYrKxSFlmzsjsh6g2fcHOa7vk9G8zr0q4944rEFsbYm0DdSDY/HgkGlz8CJSOMrvzx9 TVg3RkVeBrZaDk7xAYrZ2BK/Q+Mop8jZ4AoGBlDR94YkH0RjFQmsAcf1kLoKapRG7lc9JeDN7KHQ l3eg3qrfFG24mhAbgq187NiIKOf+KSg+XppMqz7bfuwlcJJEKTupS5XvURwhEWyJzIkwSFAW0Pw8 uiKeMUJTS2Jsxpkx+IHIsDarm2Hx5e4YMH5a+Vxo+Gz4gw56nrUo2iUXYOUfZrYt2kwya2u/aJSy +XYIL3TVXRgGu+ISfO+8Nwazmqab1cMTal0k88rkq0CsLjZ84JRIA6Ye/ajVf3YKfhRT0knXt1CR LuLMOPhV8sZiFXmtTilamlYRFmMy/B+9uFk6vL63wFNT/iH+i0krVjPg4j89ZZyO7mN7AnWnYo04 a2ey4hx/dv+muc596OjLSvKX9IT2wJHgmTBPB3ojkwVz5nkXGxmpgHMcN6qoXPjenLhIOF1oeRbs um4BtTmK88nRNTFa+st+XaoInkRdNlt33zOhWO9WO0TWS/svbnV0qSBFjIWKltiA4C3fxV8V8Cbn AWESwbg6xu2OfQrGyuxJBL08Tx1B6MUXC2YrxA3JqQGzPWUXNAL5luHEIOz7YnQP9uRZXMDdNgA/ bvpxeniqBDKdL+6MGbK4t8eoCcCPuuAofv54KaaefG3Qi6AvJQbthcIFXjU5VKFwDpe+9rZABUSO mrMA1sfhtY1GZZolCkLnLN7c0R+MPCdbWjlZ4FwOnzX+Io4BoxTkj0hGlATQgXlJtJ0i5pE2QAQR POB84MmsDrk3yRlOP34VGRo5L8M2MA2Zvy07rVJth1gDB2lpXMdbvAc7tiERbInMiTBIUBbQ/Dy6 Ip65tyiUWX+tf7ZF5CSWokMB/eSqQACX6tONkFbPlnFTwFrgPv9TQfT8VfEBrwtfkhA= X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 463yfZ4BH8z3P6w X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=cNu2WU4f; 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 [-0.85 / 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(-0.98)[-0.977,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sumeritec.com]; NEURAL_HAM_MEDIUM(-0.98)[-0.977,0]; NEURAL_SPAM_SHORT(0.56)[0.556,0]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[sumeritec.com:+]; 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]; RECEIVED_SPAMHAUS_PBL(0.00)[173.119.125.114.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; 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.05)[ip: (1.27), ipnet: 185.201.17.0/24(-1.27), asn: 49544(-0.24), country: NL(0.01)]; FROM_EQ_ENVFROM(0.00)[] 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: Thu, 08 Aug 2019 06:10:49 -0000 Hi, On Wed, 7 Aug 2019 13:26:31 -0400 Daniel Eischen wrote: > > On Aug 7, 2019, at 6:25 AM, Erich Dollansky > > wrote: > > > > Hi, > > > > On Wed, 7 Aug 2019 06:07:25 -0400 > > Daniel Eischen wrote: > > > >>> On Aug 7, 2019, at 5:20 AM, 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: > >>> > >>> If mutex is a robust mutex and the process containing the owning > >>> thread terminated while holding the mutex lock, a call to > >>> pthread_mutex_lock() shall return the error value [EOWNERDEAD]. If > >>> mutex is a robust mutex and the owning thread terminated while > >>> holding the mutex lock, a call to pthread_mutex_lock( ) may return > >>> the error value [EOWNERDEAD] even if the process in which the > >>> owning thread resides has not terminated. > >>> > >>> Note the difference between shall and may. We only process robust > >>> list on the process termination. If the process is still alive, > >>> but the thread terminated, it can only happen because the process > >>> code asked for the thread termination explicitly, and then the > >>> code should be able to keep its own state. On really fatal > >>> conditions, like unhandled signals, kernel terminates the > >>> process, not a thread. > >> > >> But pthread_mutex_lock() should not return EBUSY; that is only for > >> _trylock(). It seems to me _lock() should either return EOWNERDEAD > >> or EDEADLK, or it just blocks indefinitely. > >> > >> Erich, are you getting EBUSY for pthread_mutex_lock() or is that > >> only for pthread_mutex_trylock()? > >> > > EBUSY is only returned when I call 'pthread_mutex_trylock'. The > > other one just hangs. > > In this case, I think FreeBSD is behaving correctly. I think perhaps > the only problem is that the man page isn't reflecting the POSIX > wording. > it is not so clear. This is also the reason why I finally relied on the FreeBSD man page. It says at the bottom: The pthread_mutex_lock() function conforms to ISO/IEC 9945-1:1996 ("POSIX.1"). Which is pretty old. http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html The Open Group Base Specifications Issue 7, 2018 edition IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008) ... When you check that document out, it becomes even more confusing as it says in one case 'thread' and in the other case 'process'. This makes it a bit confusing for programmers as especially the unlock function should be only called by the thread holding the lock. How this was defined by the FreeBSD manuals made it very clear to programmers.. To come back to your comment. So, even when we assume the Open Group has the final say, pthread_mutex_unlock is wrong as it shall release the mutex when held by a dead thread but it does not. The whole thing looks to me that the author of the man page used some logic which did not make it into the software. Erich From owner-freebsd-threads@freebsd.org Thu Aug 8 20:51:05 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 84A07B23BF for ; Thu, 8 Aug 2019 20:51:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 464LBK32mGz4qk4 for ; Thu, 8 Aug 2019 20:51:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 685E7B23BE; Thu, 8 Aug 2019 20:51:05 +0000 (UTC) Delivered-To: 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 681F8B23BD for ; Thu, 8 Aug 2019 20:51:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464LBK1nflz4qk0 for ; Thu, 8 Aug 2019 20:51:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1B1232DC2 for ; Thu, 8 Aug 2019 20:51:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x78Kp4qB097631 for ; Thu, 8 Aug 2019 20:51:04 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x78Kp4IN097630 for threads@FreeBSD.org; Thu, 8 Aug 2019 20:51:04 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: threads@FreeBSD.org Subject: [Bug 227826] [FUSEFS]: fuse_main() hangs in pthread_cleanup_pop() Date: Thu, 08 Aug 2019 20:51:05 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: threads X-Bugzilla-Version: 11.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: asomers@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: threads@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 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: Thu, 08 Aug 2019 20:51:05 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D227826 --- Comment #4 from Alan Somers --- Please retest on current using the latest build (Aug-8 or later) --=20 You are receiving this mail because: You are the assignee for the bug.= From owner-freebsd-threads@freebsd.org Fri Aug 9 09:33:42 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 56FFCC39F4; Fri, 9 Aug 2019 09:33:42 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from out2-5.antispamcloud.com (out2-5.antispamcloud.com [185.201.17.5]) (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 464g6C0GZZz4JRm; Fri, 9 Aug 2019 09:33:38 +0000 (UTC) (envelope-from freebsd.ed.lists@sumeritec.com) Received: from srv31.niagahoster.com ([153.92.8.106]) by mx37.antispamcloud.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hw1HA-0005Nb-Ul; Fri, 09 Aug 2019 11:33:34 +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=hX9wl38457SNmf86WztVwtpoEIFIv6tGprCX7D7NvH8=; b=c/rn/U9V4lD7eR6gFKbtCP62Kx XfEMqAoFOYF1kTHDgiJPhp3DVqMxP/zztQKU1Sldm8XFSlsEO42TNJODCVLCXXL32dI/XnnyEBYud l4DRiOcULciaJWNzTTHcGAjHEN4c4PZYNcZnv4mhqQ722gGnlU0iDZKXgb4xQUCfOnJmBQZrioJ3g crO5t8xlzPYWN+eSPZ1aJvOjugWjIye3f+l2kl/dY3qpIlLa2bJWaOUjPKeeDCDlb4Z3WzAOYmysa zPiFnj24bT2+Mc8UT7YqzpdTf/NQc4uXwfJzduEVIH0B/VfAzNCUoMr+OtUP/d3zdYdLjW36uG1NR i56cgz9g==; Received: from [114.125.118.127] (port=23274 helo=Ryzen1.sumeritec.com) by srv31.niagahoster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hw1GI-0004ds-GR; Fri, 09 Aug 2019 16:32:44 +0700 Date: Fri, 9 Aug 2019 17:32:35 +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: <20190809173235.2b6aa029.freebsd.ed.lists@sumeritec.com> In-Reply-To: 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> <20190807182548.1a8e00dd.freebsd.ed.lists@sumeritec.com> 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+Jt8z2T3KSZWQ0mYy/5bX2tR2MxjY1He4 QIvBAg3toE6wd3PtFST6QG6oDWQr5qk8z/hipQQViX96l/tFvjme58IPsHkDAFiitpb3kg2n6/4g cUiqnb8W1xUKhGnKGbei0u7q3nc7e9tWEp4LOzvZZshxor9/dSTg127TqHZDxA/kZB41Rh+qlyJD Hkk4rmks4GDcGufSRgudzGUUerEAVH/t0RiO6pD6AS7wG2J0akSI9h0P1G6DwIE7VKe+bqpcdCns 72R1040BPtH5AjgBUwdnLhigo3PhS4R573H1viWXdj+WVBMD0NtCO8JxriscWzJ0F8DaL7mGYMmK DF5D7THA4SR2KBqj44ngr3oIWTLM+47Ewp4f27xvBBHtPpxgCVRDLa+kipBvNb5FuO0jb82+DP1/ p6PCcmi8K0ucY0Dl27Fx+mk8/adlWwzBehNktFp1Au30caV9d2aAmsqMGVOlazvzL1nhNXrZS1QT TBGlJEzGzGqRVYKU9W9tbmVXJBqdHHDmDZAR62S8fTT/GafqgXnPyyS4Hh8s12ybj3OcYQ7BbVHJ pP5+GeY+Zn45S5XkEzp7LLlWjrE6IX2XGQJt2ZBm5Fmy55tOY6IlA5v+KBmneSBlqbz7odydEhWm hX+vFWOhB7r9MEh6d5BDOmwQbH0yoWb/iFkVRsexkWLDVEhgSVkKtXsJv6yBDhKCKVr3GsqCiwQz Kw+6v3CaIMG6s7LqJBUdVk0WEIFuQsWzpA4m675OCKtJalRp40OMIBJRTodrHYxR6c/Q3Xlz0XoD m9ZKxGu9ZRSpnbN5UmZ7H68qAIVvA3QEKTMFvUWB5kl7tpOKxjiK+UpyMoLOvGB1ZueRx8OpyKA6 9LF1Ge2GaGfxmfoDzBgloy+Ctoaiw1p/73ruZHq1JMC83k5wSeWJfaTC39aepAO/K630eHPSiGhL G21rwytzyq4nhu0+m3/YUu4UQUF+p3oNM25euFxgcyJ9Hnm/BwAe1nh2Rt74x1AyEZtsbeEDapU2 quQoCNMpMCDh9jihx+Za/cV70jOJzN2r4A== X-Report-Abuse-To: spam@quarantine10.antispamcloud.com X-Rspamd-Queue-Id: 464g6C0GZZz4JRm X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sumeritec.com header.s=default header.b=c/rn/U9V; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd.ed.lists@sumeritec.com has no SPF policy when checking 185.201.17.5) smtp.mailfrom=freebsd.ed.lists@sumeritec.com X-Spamd-Result: default: False [-2.63 / 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)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[sumeritec.com]; NEURAL_HAM_LONG(-0.99)[-0.990,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-0.29)[ipnet: 185.201.17.0/24(-1.21), asn: 49544(-0.24), country: NL(0.01)]; DKIM_TRACE(0.00)[sumeritec.com:+]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.993,0]; R_SPF_NA(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[5.17.201.185.list.dnswl.org : 127.0.3.1]; RECEIVED_SPAMHAUS_PBL(0.00)[127.118.125.114.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:49544, ipnet:185.201.17.0/24, country:NL]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[] 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: Fri, 09 Aug 2019 09:33:42 -0000 Hi, On Wed, 7 Aug 2019 13:26:31 -0400 Daniel Eischen wrote: > > On Aug 7, 2019, at 6:25 AM, Erich Dollansky > > wrote: > > > >> Erich, are you getting EBUSY for pthread_mutex_lock() or is that > >> only for pthread_mutex_trylock()? > >> > > EBUSY is only returned when I call 'pthread_mutex_trylock'. The > > other one just hangs. > > In this case, I think FreeBSD is behaving correctly. I think perhaps > the only problem is that the man page isn't reflecting the POSIX > wording. I only could go back to my test program now. I made the wrong assumption that 'EOWNERDEAD' will be repeated. This error message comes only one time. The caller has then to call 'pthread_mutex_consistent' to correct the error. Having a program which misses one return value leads to the problem I have had. At least we learned with this that FreeBSD's version of pthreads is a much more practical attempt than some others. Erich