Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IPa9w-0002My-18 for qemu-devel@nongnu.org; Mon, 27 Aug 2007 04:41:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IPa9v-0002Mm-DX for qemu-devel@nongnu.org; Mon, 27 Aug 2007 04:41:19 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPa9v-0002Mj-5n for qemu-devel@nongnu.org; Mon, 27 Aug 2007 04:41:19 -0400 Received: from selda.webserv-it.de ([62.134.144.159] helo=mercenary.garni.ch) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IPa9u-0000FV-Pb for qemu-devel@nongnu.org; Mon, 27 Aug 2007 04:41:19 -0400 Received: from p548191d2.dip0.t-ipconnect.de ([84.129.145.210] helo=emperor.local) by mercenary.garni.ch with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1IPa9d-0007Kl-Ge for qemu-devel@nongnu.org; Mon, 27 Aug 2007 10:41:04 +0200 From: =?utf-8?q?J=C3=B6rg_Walter?= Date: Mon, 27 Aug 2007 10:40:47 +0200 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_P4o0G8YqTwtXSSL" Message-Id: <200708271040.47752.jwalt@garni.ch> Subject: [Qemu-devel] [PATCH] fix SMB-related lockup on some systems Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Boundary-00=_P4o0G8YqTwtXSSL Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi! I have found a bug where qemu would sit in an endless loop whenever "-smb" = was=20 enabled and accessed. It is probably the same problem some people in the us= er=20 forums talk about, and here's my analysis and fix: On glibc systems with NPTL, fork() is not atomic with regard to signals, wh= ile=20 on non-NPTL-systems, it is. This behaviour is considered to be correct by t= he=20 libc developers, as no relevant spec forbids this behaviour. See this thread for details: http://sourceware.org/ml/libc-hacker/2007-02/msg00009.html In qemu, accessing the SMB ip-address causes the slirp code to issue a fork= in=20 slirp/misc.c, which hangs, as we are in mid-emulation and SIGALARM signals= =20 come in at a high rate, probably triggering the above mentioned behaviour. This patch solves the problem by temporarily blocking all signals until the= =20 fork is over. It doesn't unblock signals in the child, as I assume that=20 executing the server program will care for that anyways. It works for me,=20 finally I can access "-smb"-folders again. =2D-=20 CU J=C3=B6rg --Boundary-00=_P4o0G8YqTwtXSSL Content-Type: text/x-diff; charset="utf-8"; name="qemu.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="qemu.diff" --- slirp/misc.c 2007-08-27 10:30:20.000000000 +0200 +++ slirp/misc.c.new 2007-08-27 10:29:50.000000000 +0200 @@ -313,6 +313,7 @@ int opt; int master; char *argv[256]; + int mask; #if 0 char buff[256]; #endif @@ -346,8 +347,10 @@ } } + mask = sigsetmask(~0); switch(fork()) { case -1: + sigsetmask(mask); lprint("Error: fork failed: %s\n", strerror(errno)); close(s); if (do_pty == 2) @@ -426,6 +429,7 @@ exit(1); default: + sigsetmask(mask); if (do_pty == 2) { close(s); so->s = master; --Boundary-00=_P4o0G8YqTwtXSSL--