From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ld9pq-00023m-RZ for qemu-devel@nongnu.org; Fri, 27 Feb 2009 16:01:30 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ld9pp-00023N-KV for qemu-devel@nongnu.org; Fri, 27 Feb 2009 16:01:30 -0500 Received: from [199.232.76.173] (port=60241 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ld9pp-00023H-Ep for qemu-devel@nongnu.org; Fri, 27 Feb 2009 16:01:29 -0500 Received: from mail-bw0-f171.google.com ([209.85.218.171]:48407) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ld9po-0007vu-Ky for qemu-devel@nongnu.org; Fri, 27 Feb 2009 16:01:29 -0500 Received: by bwz19 with SMTP id 19so1111936bwz.34 for ; Fri, 27 Feb 2009 13:01:27 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <49A843CA.2050500@us.ibm.com> References: <49A843CA.2050500@us.ibm.com> Date: Fri, 27 Feb 2009 22:01:27 +0100 Message-ID: Subject: Re: [Qemu-devel] Re: [PATCH] Fix freezing bug in curses console From: andrzej zaborowski Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Cc: Matthew Bloch , kvm@vger.kernel.org 2009/2/27 Anthony Liguori : > Matthew Bloch wrote: >> >> Hi there, >> >> We are running lots of kvm processes in screen and found that about 1 in >> 5 froze shortly after startup startup with a backtrace like this one: >> >> #0 =C2=A00xf7c7fcd9 in pthread_exit () from /lib/tls/libc.so.6 >> #1 =C2=A00xf7cfbe62 in wresize () from /lib/libncurses.so.5 >> #2 =C2=A00xf7cfb7ab in is_term_resized () from /lib/libncurses.so.5 >> #3 =C2=A00xf7cfb877 in is_term_resized () from /lib/libncurses.so.5 >> #4 =C2=A00xf7cfba31 in resize_term () from /lib/libncurses.so.5 >> #5 =C2=A00x080d3dd9 in vga_init () >> #6 =C2=A0 >> #7 =C2=A00xf7c0da5b in free () from /lib/tls/libc.so.6 >> #8 =C2=A00xf7c0effe in calloc () from /lib/tls/libc.so.6 >> #9 =C2=A00xf7cf222e in newpad () from /lib/libncurses.so.5 >> #10 0x080d3549 in vga_init () >> >> We're just using the lenny version of kvm from 2008-12-16. >> >> On casual inspection, the SIGWINCH signal handling looked ropey to me - >> grandpa always told me not to do any real work in a signal handler, and >> the backtrace suggested re-entrancy problems in curses, so I changed the >> behaviour to set a flag and do the work in the main loop instead. =C2=A0= Maybe >> I'm reading the backtrace wrong. >> >> So far that means that when you resize the window, the display is >> corrupt until the VM outputs some text, or the user hits a key. =C2=A0Bu= t I >> think it has solved the freezing / crashing bug too - would appreciate >> any comments on my analysis or proposed solution. >> > > It's racy with select(). =C2=A0A better fix would be to create a pipe and= write > to that pipe in the SIGWINCH handler. =C2=A0You should then register an i= o > callback using qemu_set_fd_handler2() that does the actions for SIGWINCH. Maybe a bottom half would work? The scheduling of a bh shouldn't constitute "real work". Cheers