From owner-freebsd-arm@freebsd.org Mon Oct 31 05:15:33 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53155C27ACF for ; Mon, 31 Oct 2016 05:15:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 376C01194 for ; Mon, 31 Oct 2016 05:15:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u9V5FXJ9032554 for ; Mon, 31 Oct 2016 05:15:33 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-arm@FreeBSD.org Subject: [Bug 213936] stable/11 -r307797 on BPi-M3 (cortex-a7): clang 3.8.0 produces bad stack code in lang/gcc6's xgcc's cc1 and so cc1 gets SIGSYS during lang/gcc6 bootstrap Date: Mon, 31 Oct 2016 05:15:33 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: arm X-Bugzilla-Version: 11.0-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: markmi@dsl-only.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-arm@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2016 05:15:33 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D213936 Bug ID: 213936 Summary: stable/11 -r307797 on BPi-M3 (cortex-a7): clang 3.8.0 produces bad stack code in lang/gcc6's xgcc's cc1 and so cc1 gets SIGSYS during lang/gcc6 bootstrap Product: Base System Version: 11.0-STABLE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: arm Assignee: freebsd-arm@FreeBSD.org Reporter: markmi@dsl-only.net [Note: lang/gcc6's xgcc's cc1 was built by clang for the stage of the lang/= gcc6 bootstrap that was in use below. So the code generation problem is clang's,= not gcc6's or xgcc's.] The below was found while trying to figure out why a bootstrap lang/gcc6 bu= ild on a armv6/cortex-a7 stable/11 -r307797 crashes in xgcc's cc1 with SIGSYS = for some of what xgcc tries to build. I'm recording this here while pursuing the system problems the context has also exposed: truss's error handling for watching the failing cc1 has crash problems of its own. The cc1 crash (when under gdb) shows a stack address as the pc value once t= he problem happens. In more detail, when ( in gcc/gimple-match-head.c ): bool gimple_resimplify1 (gimple_seq *seq, code_helper *res_code, tree type, tree *res_ops, tree (*valueize)(tree)) { . . . } returns the armv6 pc ends up with a stack address instead of a code address. [There may be other cc1 routines with similar problems. I've only analyzed = the one example stack corruption.] Eliminating the long names (mostly) in the gdb disassembly output for gimple_resimplify1 so the code is easier to see --and showing function stack-handing preamble/post-amble code only: Dump of assembler code for function _Z18gimple_resimplify1PP6gimpleP11code_helperP9tree_nodePS5_PFS5_S5_E: 0x0105d5ec push {r0, r1, r4, r6, r8, r11, sp, lr} 0x0105d5f0 add r11, sp, #16 ; 0x10 0x0105d5f4 sub sp, sp, #88 ; 0x58 . . . 0x0105d7e0 sub sp, r11, #16 ; 0x10 0x0105d7e4 pop {r4, r5, r6, r10, r11, pc} Note that, just after restoring sp to its value from just after the push, t= he pop does not match the push and restores what was r11 (a pointer into the stack) to the pc register, matching the observed behavior that gdb shows: execution of stack contents. I have used stepi in gdb to go up to and through the pop and so have seen t= he evidence of the corruption fairly directly: just after the pop things are messed up in gdb with a stack address shown for the pc value. So it is a code generation defect for at least armv6 / cortext-a7. Context details: root@bananapi-m3:/usr/obj/portswork/usr/ports/lang/gcc6/work/.build/armv6-p= ortbld-freebsd11.0/libgcc # svnlite info /mnt/usr/ports | grep "Re[lv]" Relative URL: ^/head Revision: 424540 Last Changed Rev: 424540 root@bananapi-m3:/usr/obj/portswork/usr/ports/lang/gcc6/work/.build/armv6-p= ortbld-freebsd11.0/libgcc # uname -apKU FreeBSD bananapi-m3 11.0-STABLE FreeBSD 11.0-STABLE #0 r307797M: Sat Oct 29 10:54:45 PDT 2016=20=20=20=20 markmi@FreeBSDx64:/usr/local/src/crochet/work/obj/arm.armv6/usr/src/sys/ALL= WINNER arm armv6 1100505 1100505 (So stable/11 -r307797 was built with crochet, not with my usual procedure.) The crashing cc1 shows crash problems in truss. ktrace reports odd informat= ion from the stack corruption as well but does not crash. So for now the environment with all these issues is being kept in a form appropriate to testing the stable/11 truss issue(s). For example John Baldw= in is working on truss for the its issue(s) and when he asks I rebuild world/kernel with his truss related updates and report what happened. (truss does not work yet for handling the cc1 failure as of when I wrote this.) root@bananapi-m3:/usr/obj/portswork/usr/ports/lang/gcc6/work/.build/armv6-p= ortbld-freebsd11.0/libgcc # more /etc/make.conf=20 DEFAULT_VERSIONS+=3Dperl5=3D5.22 WRKDIRPREFIX=3D/usr/obj/portswork WITH_DEBUG=3D WITH_DEBUG_FILES=3D MALLOC_PRODUCTION=3D # CFLAGS+=3D -mcpu=3Dcortex-a7 CXXFLAGS+=3D -mcpu=3Dcortex-a7 CPPFLAGS+=3D -mcpu=3Dcortex-a7 So -mcpu=3Dcortex-a7 was part of the CFLAGS/CXXFLAGS context while lang/gcc= 6 was being built. I'm not trying alternatives for such for now as I'm keeping the truss-testing context in place. --=20 You are receiving this mail because: You are the assignee for the bug.=