From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTOlz-0008OF-5P for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:48:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTOlu-000851-1R for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:48:06 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTOlt-00084r-Uv for qemu-devel@nongnu.org; Mon, 19 Mar 2007 15:48:01 -0500 Received: from nigiri.palats.com ([82.227.4.70]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HTOkO-0001v5-U6 for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:46:29 -0400 From: Pierre Palatin Subject: Re: [Qemu-devel] qemu/linux-user main.c Date: Mon, 19 Mar 2007 21:46:24 +0100 References: <1174333564.24702.14.camel@rapid> <20070319201311.GH28895@networkno.de> In-Reply-To: <20070319201311.GH28895@networkno.de> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_gav/FddfVUK0EvV" Message-Id: <200703192146.24598.pierre.palatin@m4tp.org> 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=_gav/FddfVUK0EvV Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Monday 19 March 2007 21:13:12 Thiemo Seufer wrote: > J. Mayer wrote: > > On Mon, 2007-03-19 at 12:16 +0000, Thiemo Seufer wrote: > > > CVSROOT: /sources/qemu > > > Module name: qemu > > > Changes by: Thiemo Seufer 07/03/19 12:16:29 > > > > > > Modified files: > > > linux-user : main.c > > > > > > Log message: > > > Support -cpu selection for mips usermode emulation. Fix segfault when > > > dispaying the -cpu list help. > > > > Could you tell more about the segfault ? > > It segfaulted for me (on ppc/linux) after printing the help list. > > > exit is used at many other places without any problem and furthermore I > > did not experiment any crash while testing the PowerPC target with the > > initial patch, so ? (I'd really like to understand...) > > I didn't really debug it, but I noticed the other branch in the > conditional uses _exit() instead of exit(). With that change, the > segfault disappeared. I figure we have an atexit/on_exit call somwhere > which tries to use data which isn't initialized at that point. Maybe that's related to the problem i've got (in http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00110.html ). There is some piece of code in main.c which mess around libc initialization & exit and were making my qemu-i386 segfault really early. It seems it was designed to avoid a bug in some versions of glibc. I attach the simple patch I've made to avoid that. It may need adjustements since I don't know enough about libc internals on initialization to be sure that's the correct fix - I would be deeply interested in some input/comments on this problem. Pierre Palatin --Boundary-00=_gav/FddfVUK0EvV Content-Type: text/x-diff; charset="iso-8859-1"; name="init-segfault.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="init-segfault.patch" Index: linux-user/main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- linux-user/main.c (r=E9vision 527) +++ linux-user/main.c (copie de travail) @@ -44,7 +44,7 @@ =20 /* for recent libc, we add these dummy symbols which are not declared when generating a linked object (bug in ld ?) */ =2D#if (__GLIBC__ > 2 || (__GLIBC__ =3D=3D 2 && __GLIBC_MINOR__ >=3D 3)) &&= !defined(CONFIG_STATIC) +#if (__GLIBC__ =3D=3D 2 && __GLIBC_MINOR__ =3D=3D 3) && !defined(CONFIG_ST= ATIC) long __preinit_array_start[0]; long __preinit_array_end[0]; long __init_array_start[0]; --Boundary-00=_gav/FddfVUK0EvV--