From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK6E7-0002kk-4G for qemu-devel@nongnu.org; Mon, 25 Mar 2013 08:10:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UK6E5-0006PZ-Fd for qemu-devel@nongnu.org; Mon, 25 Mar 2013 08:10:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK614-0001qJ-FB for qemu-devel@nongnu.org; Mon, 25 Mar 2013 07:56:42 -0400 Date: Mon, 25 Mar 2013 07:56:38 -0400 From: Luiz Capitulino Message-ID: <20130325075638.26586594@redhat.com> In-Reply-To: <51500001.1060109@redhat.com> References: <514C21C6.3070800@greensocs.com> <20130322165039.32aae1fb@doriath> <20130322173904.66d2f5ce@doriath> <51500001.1060109@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Abort in monitor_puts. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Anthony Liguori , qemu-devel , KONRAD =?UTF-8?B?RnLDqWTDqXJpYw==?= On Mon, 25 Mar 2013 08:42:57 +0100 Gerd Hoffmann wrote: > On 03/22/13 22:39, Luiz Capitulino wrote: > > On Fri, 22 Mar 2013 16:50:39 -0400 > > Luiz Capitulino wrote: > >=20 > >> On Fri, 22 Mar 2013 10:17:58 +0100 > >> KONRAD Fr=C3=A9d=C3=A9ric wrote: > >> > >>> Hi, > >>> > >>> Seems there is an issue with the current git (found by toddf on IRC). > >>> > >>> To reproduce: > >>> > >>> ./qemu-system-x86_64 --monitor stdio --nographic > >>> > >>> and put "?" it should abort. > >>> > >>> Here is the backtrace: > >>> > >>> #0 0x00007f77cd347935 in raise () from /lib64/libc.so.6 > >>> #1 0x00007f77cd3490e8 in abort () from /lib64/libc.so.6 > >>> #2 0x00007f77cd3406a2 in __assert_fail_base () from /lib64/libc.so.6 > >>> #3 0x00007f77cd340752 in __assert_fail () from /lib64/libc.so.6 > >>> #4 0x00007f77d1c1f226 in monitor_puts (mon=3D, > >>> str=3D) at=20 > >> > >> Yes, it's easy to reproduce. Bisect says: > >> > >> f628926bb423fa8a7e0b114511400ea9df38b76a is the first bad commit > >> commit f628926bb423fa8a7e0b114511400ea9df38b76a > >> Author: Gerd Hoffmann > >> Date: Tue Mar 19 10:57:56 2013 +0100 > >> > >> fix monitor > >> =20 > >> chardev flow control broke monitor, fix it by adding watch support. > >> =20 > >> Signed-off-by: Anthony Liguori > >> > >> My impression is that monitor_puts() in being called in parallel. > >=20 > > Not all. > >=20 > > What's happening is that qemu_chr_fe_write() is returning < 0, > > mon->outbuf_index is not reset and is full, this causes the assert in > > monitor_puts() to trig. > >=20 > > The previous version of monitor_flush() ignores errors, and everything > > works, so doing the same thing here fixes the problem :) >=20 > No, ignoring errors breaks qmp because the output isn't valid json any > more when you cut off something ... What you mean "when you cut off"? When the other side disconnects? Do we ca= re? > > For some reason I'm unable to see what the error code is. Gerd, do you = think > > the patch below is reasonable? If it's not, how should we handle errors= here? >=20 > No, it's not. >=20 > Ignoring the error for errno =3D EAGAIN breaks flow control. >=20 > Ignoring the error for errno !=3D EAGAIN (and maybe logging a debug > message) would be ok, but I suspect it's actually EAGAIN you get here. >=20 > Just go for a larger buffer? That's simple, but it's not a real fix. We hit that problem because the help output is a large one. I'd guess that this is easily reproduced with something like QIDL, which (iirc) generates long json output on QMP. Looks like we need a dynamic buffer there. Other ideas?