From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTPA8-0003Vy-6x for qemu-devel@nongnu.org; Mon, 19 Mar 2007 17:13:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTPA5-0003VZ-NJ for qemu-devel@nongnu.org; Mon, 19 Mar 2007 17:13:02 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTPA5-0003VW-GV for qemu-devel@nongnu.org; Mon, 19 Mar 2007 16:13:01 -0500 Received: from phoenix.bawue.net ([193.7.176.60] helo=mail.bawue.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HTP8a-0007MX-7x for qemu-devel@nongnu.org; Mon, 19 Mar 2007 17:11:28 -0400 Date: Mon, 19 Mar 2007 21:10:13 +0000 Subject: Re: [Qemu-devel] qemu/linux-user main.c Message-ID: <20070319211013.GI28895@networkno.de> References: <1174333564.24702.14.camel@rapid> <20070319201311.GH28895@networkno.de> <200703192146.24598.pierre.palatin@m4tp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <200703192146.24598.pierre.palatin@m4tp.org> From: Thiemo Seufer Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pierre Palatin Cc: qemu-devel@nongnu.org Pierre Palatin wrote: > 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 w= hen > > > > 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. >=20 > Maybe that's related to the problem i've got (in=20 > 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 initializati= on &=20 > exit and were making my qemu-i386 segfault really early. It seems it was= =20 > designed to avoid a bug in some versions of glibc. > I attach the simple patch I've made to avoid that.=20 > It may need adjustements since I don't know enough about libc internals o= n=20 > initialization to be sure that's the correct fix - I would be deeply=20 > interested in some input/comments on this problem. >=20 > Pierre Palatin > 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 > --- 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 ?) */ > -#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_= STATIC) > long __preinit_array_start[0]; > long __preinit_array_end[0]; > long __init_array_start[0]; binutils' ld had a bug a while ago, this looks like a workaround for it (which means the check for glibc is wrong, and there's no easy way to do it right). Commenting out that code made no difference to me. Thiemo