From patchwork Wed Aug 27 23:06:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 2561 Received: (qmail 12225 invoked by alias); 27 Aug 2014 23:06:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 12215 invoked by uid 89); 27 Aug 2014 23:06:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: toccata.ens-lyon.org Date: Thu, 28 Aug 2014 01:06:25 +0200 From: Samuel Thibault To: Roland McGrath Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH,Hurd] Fix hang on fork Message-ID: <20140827230625.GW3343@type.youpi.perso.aquilenet.fr> Mail-Followup-To: Roland McGrath , libc-alpha@sourceware.org, bug-hurd@gnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) If e.g. a signal is being received while we are running fork(), the signal thread may be having our SS lock when we make the space copy, and thus in the child we can not take the SS lock any more. * sysdeps/mach/hurd/fork.c (__fork): Lock SS->lock around __proc_dostop() call. Signed-off-by: Samuel Thibault --- sysdeps/mach/hurd/fork.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sysdeps/mach/hurd/fork.c +++ b/sysdeps/mach/hurd/fork.c @@ -130,9 +130,13 @@ __fork (void) ports_locked = 1; + /* Keep our SS locked while stopping other threads, so they don't get a + * chance to be having it locked in the copied space. */ + __spin_lock(&ss->lock); /* Stop all other threads while copying the address space, so nothing changes. */ err = __proc_dostop (_hurd_ports[INIT_PORT_PROC].port, ss->thread); + __spin_unlock(&ss->lock); if (!err) { stopped = 1;