From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LBTev-0008OZ-KB for qemu-devel@nongnu.org; Sat, 13 Dec 2008 07:31:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LBTet-0008NQ-2M for qemu-devel@nongnu.org; Sat, 13 Dec 2008 07:31:48 -0500 Received: from [199.232.76.173] (port=52636 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LBTer-0008N5-Ux for qemu-devel@nongnu.org; Sat, 13 Dec 2008 07:31:46 -0500 Received: from soufre.accelance.net ([213.162.48.15]:64405) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LBTer-0001Do-HQ for qemu-devel@nongnu.org; Sat, 13 Dec 2008 07:31:45 -0500 Received: from [192.168.0.3] (potipota.net [88.168.176.51]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by soufre.accelance.net (Postfix) with ESMTP id A83D34504D for ; Sat, 13 Dec 2008 13:31:43 +0100 (CET) Subject: Re: [Qemu-devel] Re: [linux-user] Fixed Qemu crash using Gdbstub From: Lionel Landwerlin In-Reply-To: <49438B8B.8050709@web.de> References: <1229125944.3898.39.camel@cocoduo.atr> <1229126410.3898.42.camel@cocoduo.atr> <49438B8B.8050709@web.de> Content-Type: text/plain; charset=UTF-8 Date: Sat, 13 Dec 2008 13:31:41 +0100 Message-Id: <1229171501.3898.53.camel@cocoduo.atr> Mime-Version: 1.0 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 Le samedi 13 d=C3=A9cembre 2008 =C3=A0 11:16 +0100, Jan Kiszka a =C3=A9cr= it : > Lionel Landwerlin wrote: > > I just forgot to remove 2 printf ... > > Here the good patch : > >=20 > >=20 > >=20 > >=20 > >>From 2b3fe65ea3f2ee8dd3efbb52b66a2f4e53b788ea Mon Sep 17 00:00:00 200= 1 > > From: Lionel Landwerlin > > Date: Sat, 13 Dec 2008 00:32:04 +0100 > > Subject: [PATCH] [linux-user] Fixed Qemu crash using Gdbstub > >=20 > > When using gdb with qemu (via gdbstub), if your emulated > > application is multithreaded and does a segfault then qemu > > crashes. > >=20 > > Qemu crashes because the break/watch points are shared between > > cpus. The TAILQ structure which handles the list of break/watch > > points is copied inside each CPUState structure. When the last > > breakpoint is removed (this happens on a segfault), it is > > removed across all cpus but because of the copied TAILQ > > structure a same breakpoint can be freed N times with N the > > current number of cpus. >=20 > OK, now I got the problem: user space emulation spawns additional VCPUs > to emulate fork. Those VCPUs are cloned via cpu_copy which simply > duplicates the CPUState of the parent, including the breakpoint and > watchpoint TAILQ headers. This is doomed to fail. >=20 > But your approach to let the cloned VCPU point to the same TAILQ header > as its parent is not correct as well. It will cause troubles to gdbstub > which manages breakpoints on all VCPUs by adding duplicate instances on > a per-VCPU base. If you inject a breakpoint before a fork and then > remove it afterwards, gdbstub will report an error because it will only > find the breakpoint once, not n times (n =3D number of VCPUs). >=20 > What you have to do is to cleanly duplicate the breakpoint and > watchpoint lists on cpu_copy (filter out BP_CPU types for cleanness > reasons, although they do not occur in user emulation ATM). Hello Jan, Thanks for reviewing my patch. Duplication of all break/watchpoints will makes the patch bigger, because it will required break/watchpoint_copy functions etc... Another problem is that threads are also emulated by vcpus in user emulation. But we also need to share break/watchpoints between threads. This explain the way my patch do the thing. Finally, this makes the modification a lot more complicated than what I expected, because breakpoints on emulated forks should not apply. --=20 =EF=BB=BFLione Landwerlin =20 =EF=BB=BF O p e n W i d e 14, rue Gaillon 75002 Paris