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"