From owner-freebsd-threads@freebsd.org Tue Dec 6 10:59:25 2016 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44E44C6AAA0 for ; Tue, 6 Dec 2016 10:59:25 +0000 (UTC) (envelope-from dimitri.staessens@intec.ugent.be) Received: from smtp2.ugent.be (smtp2.ugent.be [157.193.49.126]) (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 07F6D2BB for ; Tue, 6 Dec 2016 10:59:24 +0000 (UTC) (envelope-from dimitri.staessens@intec.ugent.be) Received: from localhost (mcheck3.ugent.be [157.193.71.89]) by smtp2.ugent.be (Postfix) with ESMTP id 19822B2402 for ; Tue, 6 Dec 2016 11:51:56 +0100 (CET) X-Virus-Scanned: by UGent DICT Received: from smtp2.ugent.be ([157.193.49.126]) by localhost (mcheck3.ugent.be [157.193.43.11]) (amavisd-new, port 10024) with ESMTP id MqnrulxLzhIm for ; Tue, 6 Dec 2016 11:51:55 +0100 (CET) Received: from mail2.intec.ugent.be (mail2.intec.ugent.be [157.193.214.245]) by smtp2.ugent.be (Postfix) with ESMTP id C0245B2253 for ; Tue, 6 Dec 2016 11:51:55 +0100 (CET) Received: from [10.10.131.46] (hal.ilabt.iminds.be [193.191.148.129]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: dstaesse) by mail2.intec.ugent.be (Postfix) with ESMTPSA id A16E82D for ; Tue, 6 Dec 2016 11:51:55 +0100 (CET) From: Dimitri Staessens Subject: Unlocking a robust mutex in a cleanup handler To: freebsd-threads@freebsd.org Message-ID: <119e59d4-6125-f313-e6e6-67055a15d224@intec.ugent.be> Date: Tue, 6 Dec 2016 11:49:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-Miltered: at jchkm3 with ID 5846984B.003 by Joe's j-chkmail (http://helpdesk.ugent.be/email/)! X-j-chkmail-Enveloppe: 5846984B.003 from mail2.intec.ugent.be/mail2.intec.ugent.be/157.193.214.245/mail2.intec.ugent.be/ X-j-chkmail-Score: MSGID : 5846984B.003 on smtp2.ugent.be : j-chkmail score : . : R=. U=. O=. B=0.000 -> S=0.000 X-j-chkmail-Status: Ham Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2016 10:59:25 -0000 Dear devs, first of all, thank you for supporting robust mutexes in FreeBSD 11. I'm having some issues with a thread that holds a robust mutex (residing in a POSIX shared memory (shm) segment) in conjunctions with a condition variable (also in that POSIX shm) on which that thread is blocked via a pthread_cond_wait() call. pthread_cond_wait tries to retake the mutex after the thread cancellation signal is received, and there is a pthread_mutex_unlock pushed to the cleanup stack to unlock that robust mutex in case of a cancellation. Cancelling that thread works fine on Linux, however, on FreeBSD 11.0-RELEASE, if I pthread_cancel that thread I can't get past the following check and resulting PANIC call: https://github.com/freebsd/freebsd/blob/master/lib/libthr/thread/thr_mutex.c#L187 After removing the check and recompiling libthr everything seems to work fine. Could this be a bug in libthr or am I missing a nuance in the use of a shared robust mutexes in conjunction with condition variables? Kind regards, Dimitri -- Dimitri Staessens Ghent University - imec Dept. of Information Technology (INTEC) Internet Based Communication Networks and Services Technologiepark 15 9052 Zwijnaarde T: +32 9 331 48 70 F: +32 9 331 48 99