From patchwork Thu Feb 6 06:57:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1234150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519007-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=R/QqxMg+; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Cq4b4V0bz9sRm for ; Thu, 6 Feb 2020 17:57:32 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=pfTsHf+aTAesKjNue9ltLAtdTdlKSWhT8wHFtCPWu7PK71S409QC+ bdi9kMRfjTmJMdQq1Flx/Hacq63KCx8b8CtbS+QOmnvBeLYtbZYSJhE1fIGi49gx ITW2NVfueI3y/HkLVVbYb2BYv9JoLL/a2R3T8FuID1RsSB1OhJf6QI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=L5MiyUQ/pL31mnI4qlwX92xw2+Y=; b=R/QqxMg+fBSPjI3Kl8k8 iEpyRrAUznghNiLLLMniBGCs/6JCQGPdw4FV3m0DJ7rQWSUzaA46fbqt3Wxto+Z+ icj19BbJ2D/fQgPs1vLNsYtVcQ2Hb8//dnsHI4wwpqFpPru01f+kAfQG/38PuHME cI9tbNtlK+4zU0cneipW+dw= Received: (qmail 32830 invoked by alias); 6 Feb 2020 06:57:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32815 invoked by uid 89); 6 Feb 2020 06:57:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=activating, compliance, sk:persona, fighter X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2020 06:57:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1F690117D88; Thu, 6 Feb 2020 01:57:21 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Jsbt9PGttpuC; Thu, 6 Feb 2020 01:57:21 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 713FE117D86; Thu, 6 Feb 2020 01:57:20 -0500 (EST) Received: from livre.home (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 0166vDLj600188 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Feb 2020 03:57:13 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [FYI] [Ada] Initialize barrier_cache for ARM EH ABI compliance Date: Thu, 06 Feb 2020 03:57:13 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 The ARM Exception Handling ABI requires personality functions in phase1 to initialize barrier_cache before returning _URC_HANDLER_FOUND, and we don't. Although our own ARM personality function does not use barrier_cache at all, other languages' ARM personality functions, during phase2, are allowed and expected to test barrier_cache.sp to check whether the handler frame was reached, which implies that personality functions is in charge of the frame, and the remaining fields of barrier_cache hold whatever values it put there in phase1. Since we did not set barrier_cache.sp, an earlier exception, already handled by a non-Ada handler and then released, may have its storage reused for a new exception, that phase1 matches to an Ada frame, but if that leaves barrier_cache.sp alone, the phase2 personality function that handled the earlier exception, upon reaching the frame that handled the earlier exception, may believe the information in barrier_cache applies to the current exception. The C++ personality function, for example, would take the information in the barrier_cache and end up activating the handler that handled the earlier exception: try { throw 1; } catch (int i) { std::cout << "caught " << i << " by c++" << std::endl; } raise_ada_exception (); // might loop back to the handler above Regstrapped on x86_64-linux-gnu (no change expected), and tested on ARM-based systems that use the ARM EH ABI. I'm checking this in. for gcc/ada/ChangeLog * raise-gcc.c (personality_body) [__ARM_EABI_UNWINDER__]: Initialize barrier_cache.sp when ending phase1. --- ada/raise-gcc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git gcc/ada/raise-gcc.c gcc/ada/raise-gcc.c index 1ba8af1..3b6c21fc 100644 --- gcc/ada/raise-gcc.c +++ gcc/ada/raise-gcc.c @@ -1211,6 +1211,16 @@ personality_body (_Unwind_Action uw_phases, } else { +#ifdef __ARM_EABI_UNWINDER__ + /* Though we do not use this field ourselves, initializing + it is required by the ARM EH ABI before a personality + function in phase1 returns _URC_HANDLER_FOUND, so that + any personality function can use it in phase2 to test + whether the handler frame was reached. */ + uw_exception->barrier_cache.sp + = _Unwind_GetGR (uw_context, UNWIND_STACK_REG); +#endif + #ifndef CERT /* Trigger the appropriate notification routines before the second phase starts, when the stack is still intact. First install what