From owner-freebsd-current@FreeBSD.ORG Thu Sep 18 21:14:43 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C90F1065670 for ; Thu, 18 Sep 2008 21:14:43 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 28F4C8FC1A for ; Thu, 18 Sep 2008 21:14:43 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.3/8.14.3/NETPLEX) with ESMTP id m8ILEdFr024711; Thu, 18 Sep 2008 17:14:39 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Thu, 18 Sep 2008 17:14:41 -0400 (EDT) Date: Thu, 18 Sep 2008 17:14:39 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: David Naylor In-Reply-To: <200809182122.08221.naylor.b.david@gmail.com> Message-ID: References: <200809180631.47071.naylor.b.david@gmail.com> <48D2807A.1050106@elischer.org> <200809182122.08221.naylor.b.david@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-current@freebsd.org, Julian Elischer Subject: Re: FreeBSD deadlock (with fork?) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Sep 2008 21:14:43 -0000 On Thu, 18 Sep 2008, David Naylor wrote: > On Thursday 18 September 2008 18:23:22 you wrote: >> David Naylor wrote: >>> Hi, >>> >>> I have a program that spawns a lot of subprocesses (with pipes open) from >>> multiple threads. The problem is the program often deadlocks, but not >>> consistently. Sometimes the program can run over 5 times to competition >>> without incidence and yet othertimes it locks within a few seconds. >> >> you sent this to -current. Is it in -current? (we fixed something like >> this some months back in current and 7) > > -current cvsuped about Tuesday. > >> do your post-fork processes do an exec? according to the spec they >> should. > > Yes, they do. See the other replies... > >> if any of your threads other than the one that did the fork ho;ds any >> mutex at teh time of fork then your process will hang. If they hold a >> umtx (between processes) then everything will hang. > > Yes, the system does make use of mutexes. The forking thread never holds a > mutex but other threads could hold a mutex. This would explain the problem. > Is there any way to get around it (i.e. make sure no mutexes are held when a > fork is called?) You can hold mutexes while forking, you just can't rely on their state in any child process. There is also pthread_atfork(). -- DE