qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thiemo Seufer <ths@networkno.de>
To: "Jörg Walter" <jwalt@garni.ch>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] fix SMB-related lockup on some systems
Date: Thu, 13 Sep 2007 04:00:23 +0100	[thread overview]
Message-ID: <20070913030023.GD15247@networkno.de> (raw)
In-Reply-To: <200708271040.47752.jwalt@garni.ch>

Jörg Walter wrote:
> Hi!
> 
> I have found a bug where qemu would sit in an endless loop whenever "-smb" was 
> enabled and accessed. It is probably the same problem some people in the user 
> forums talk about, and here's my analysis and fix:
> 
> On glibc systems with NPTL, fork() is not atomic with regard to signals, while 
> on non-NPTL-systems, it is. This behaviour is considered to be correct by the 
> 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 
> slirp/misc.c, which hangs, as we are in mid-emulation and SIGALARM signals 
> come in at a high rate, probably triggering the above mentioned behaviour.
> 
> This patch solves the problem by temporarily blocking all signals until the 
> fork is over. It doesn't unblock signals in the child, as I assume that 
> executing the server program will care for that anyways. It works for me, 
> finally I can access "-smb"-folders again.
> 
> -- 
> CU
>   Jörg

> --- 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;

Could you rewrite this using pthread_sigmask, to make it thread safe?


Thiemo

      reply	other threads:[~2007-09-13  3:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-27  8:40 [Qemu-devel] [PATCH] fix SMB-related lockup on some systems Jörg Walter
2007-09-13  3:00 ` Thiemo Seufer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070913030023.GD15247@networkno.de \
    --to=ths@networkno.de \
    --cc=jwalt@garni.ch \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).