Received: from [140.186.70.92] (port=35495 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMRot-0003eV-B4 for qemu-devel@nongnu.org; Sat, 27 Nov 2010 15:56:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PMRor-0005c2-Vu for qemu-devel@nongnu.org; Sat, 27 Nov 2010 15:56:31 -0500 Received: from adelie.canonical.com ([91.189.90.139]:49468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PMRor-0005br-N0 for qemu-devel@nongnu.org; Sat, 27 Nov 2010 15:56:29 -0500 Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1PMRop-0004Hj-9m for ; Sat, 27 Nov 2010 20:56:27 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 9591B2E8292 for ; Sat, 27 Nov 2010 20:56:03 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Sat, 27 Nov 2010 20:47:43 -0000 From: Brian Harring Sender: bounces@canonical.com References: <20101007125628.8009.23815.malonedeb@soybean.canonical.com> Message-Id: <20101127204743.5544.37859.malone@potassium.ubuntu.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 656285] Re: arm-semi mishandling SYS_HEAPINFO Reply-To: Bug 656285 <656285@bugs.launchpad.net> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Pardon, badly phrased on my part- basically we can get either -1 or old. If we changed that conditional w/in arm-semi.c to: if (-1 !=3D limit && limit !=3D ts->heap_base) { that should do the trick in a cross platform way, although we'll have to tweak the for loop to handle when limit degrades to 0. Note that this isn't the only spot that has the -1 assumption- m68-semi.c is the same. Also, linux-user/m68k-sim.c looks a bit odd in light of this discussion (that one I don't quite get- it checks for -ENOMEM which is supposed to be an alpha only return). -- = arm-semi mishandling SYS_HEAPINFO https://bugs.launchpad.net/bugs/656285 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Bug description: I am running qemu-arm on a 32-bit fedora-7 i386 machine: $ /home/bri0633/users/clarkes/qemu/build/arm-linux-user/qemu-arm --version qemu-arm version 0.12.3, Copyright (c) 2003-2008 Fabrice Bellard When I try to run an arm semi-hosted executable, I sometimes get unexpected= segv and sometimes not, depending on the executable. The symptom is: $ /home/bri0633/users/clarkes/qemu/build/arm-linux-user/qemu-arm -cpu corte= x-a9 -- a.out qemu: uncaught target signal 11 (Segmentation fault) - core dumped Segmentation fault It appear to be because of the handling of the SYS_HEAPINFO syscall in arm-= semi.c. There it tries to allocate 128M for the heap by calling do_brk() w= hich calls target_mmap(). This is the DEBUG_MMAP diagnostic: mmap: start=3D0x00009000 len=3D0x08001000 prot=3Drw- flags=3DMAP_FIXED MAP_= ANON MAP_PRIVATE fd=3D0 offset=3D00000000 but this mmap is failing because there are shared libraries (and the gate p= age) mapped there: $ ldd /home/bri0633/users/clarkes/qemu/build/arm-linux-user/qemu-arm linux-gate.so.1 =3D> (0x00880000) librt.so.1 =3D> /lib/librt.so.1 (0x03409000) libpthread.so.0 =3D> /lib/libpthread.so.0 (0x00d7d000) libm.so.6 =3D> /lib/libm.so.6 (0x00d4b000) libc.so.6 =3D> /lib/libc.so.6 (0x00bf5000) /lib/ld-linux.so.2 (0x00bd6000) However, it seems that the code in arm-semi.c does not interpret the result= of do_brk() correctly, and thinks that the mapping succeeded. The following patch appears to fix the problem: $ diff -u arm-semi.c.orig arm-semi.c --- arm-semi.c.orig 2010-09-21 13:19:15.000000000 +0100 +++ arm-semi.c 2010-10-07 13:23:13.000000000 +0100 @@ -475,7 +475,7 @@ /* Try a big heap, and reduce the size if that fails. */ for (;;) { ret =3D do_brk(limit); - if (ret !=3D -1) + if (ret =3D=3D limit) break; limit =3D (ts->heap_base >> 1) + (limit >> 1); } Do you think this is a genuine bug? Steve.