From owner-freebsd-arm@freebsd.org Sat Mar 30 19:51:36 2019 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32B64156054A for ; Sat, 30 Mar 2019 19:51:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4410734D9 for ; Sat, 30 Mar 2019 19:51:35 +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 mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id CB82D6E for ; Sat, 30 Mar 2019 19:51:34 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x2UJpYmF056206 for ; Sat, 30 Mar 2019 19:51:34 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x2UJpYEi056205 for freebsd-arm@FreeBSD.org; Sat, 30 Mar 2019 19:51:34 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: freebsd-arm@FreeBSD.org Subject: [Bug 236905] LLVM's implementation of __gcc_personality_v0 does not correctly initialise the context Date: Sat, 30 Mar 2019 19:51:34 +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: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: theraven@FreeBSD.org 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.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Mar 2019 19:51:36 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D236905 Bug ID: 236905 Summary: LLVM's implementation of __gcc_personality_v0 does not correctly initialise the context Product: Base System Version: CURRENT Hardware: arm OS: Any Status: New Severity: Affects Many People Priority: --- Component: arm Assignee: freebsd-arm@FreeBSD.org Reporter: theraven@FreeBSD.org When __gcc_personality_v0 is invoked (when exceptions unwind through C code that needs to run cleanups), it calls _Unwind_GetLanguageSpecificData: https://github.com/freebsd/freebsd/blob/56c04b0bcfcd116f1b13087ec13bcba2d8d= c7705/contrib/compiler-rt/lib/builtins/gcc_personality_v0.c#L205 This is completely fine on most architectures, but on ARM this tries to map from the context to the exception structure. The GNU extension to the APCS requires that the personality function stores this pointer in the context in register 12 (reserved as a linker scratch register, so never actually used = in unwinding).=20=20 The abstraction layer used in libcxxrt does this automatically: https://github.com/pathscale/libcxxrt/blob/f96846efbfd508f66d91fcbbef5dd808= 947c7f6d/src/unwind-arm.h#L223 It appears that the LLVM implementation of the personality routine does not= do this. This can be fixed by adding: ``` _Unwind_SetGR(context, 12, reinterpret_cast(exceptionObject)= ); ``` on entry to the personality routine. This will want to be done upstream, b= ut we should carry a local patch to compiler-rt (and possibly issue an EN) bec= ause at present any program that tries to throw an exception through C stack fra= mes crashes on ARM. --=20 You are receiving this mail because: You are the assignee for the bug.=