Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HPyrg-0006AX-Em for qemu-devel@nongnu.org; Sat, 10 Mar 2007 05:31:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HPyre-00067A-PH for qemu-devel@nongnu.org; Sat, 10 Mar 2007 05:31:51 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HPyre-000671-Hp for qemu-devel@nongnu.org; Sat, 10 Mar 2007 05:31:50 -0500 Received: from nigiri.palats.com ([82.227.4.70]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HPyrD-0002qT-UU for qemu-devel@nongnu.org; Sat, 10 Mar 2007 05:31:24 -0500 From: Pierre Palatin Date: Sat, 10 Mar 2007 11:31:15 +0100 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_zjo8FnAEvU1xwNy" Message-Id: <200703101131.15921.pierre.palatin@m4tp.org> Subject: [Qemu-devel] [PATCH] Avoid immediate segfault of qemu-i386 on x86_64 host 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=_zjo8FnAEvU1xwNy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I've got a systematic segfault in qemu-i386 ( 0.8.2, 0.9.0 and CVS, but not 0.8.1) on my x86_64. The segfault happens in glibc (2.4) initialization phase, before main : Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x000000006004a06f in __libc_csu_init () #2 0x00002acb8cc1dbce in __libc_start_main (main=0x60005120
, argc=1, ubp_av=0x7fff1e3192e8, init=0x6004a010 <__libc_csu_init>, fini=0x2acb8cf39270 , rtld_fini=0x2acb8c799c30 <_dl_fini>, stack_end=0x7fff1e3192d8) at libc-start.c:190 #3 0x0000000060004b89 in _start () Basically, it tries to call a function through a function pointer, but this pointer is NULL, hence the segfault. The problems lies in the declaration in linux-user/main.c of __init_array_start variable and friends. Simply removing them do the trick and makes qemu-i386 work nicely. I don't really know why this is here; commit tells "RH9 fix - path patch" and code comment refers to a probable bug in ld. So I've just changed (in the attached patch) glibc requirement for those variable declarations from glibc>=2.3 to glibc == 2.3. I guess it would need additional tests on a more wide variety of hosts. Pierre Palatin --Boundary-00=_zjo8FnAEvU1xwNy Content-Type: text/x-diff; charset="us-ascii"; 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=_zjo8FnAEvU1xwNy--