From patchwork Tue May 30 07:20:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 100583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1995655vqr; Tue, 30 May 2023 00:24:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ667tvSg2XzjrX3soozjUpBOTb78xq+L50MdMaXhLQYHjJcs9i0WOskuokGdU6zxCo9cAZ8 X-Received: by 2002:aa7:c616:0:b0:50b:c9d7:8b24 with SMTP id h22-20020aa7c616000000b0050bc9d78b24mr828309edq.6.1685431454827; Tue, 30 May 2023 00:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685431454; cv=none; d=google.com; s=arc-20160816; b=orjWsVBiYbAKbVqpzm29fMAzlZvz5ejNl0yHj+Tg93Q3Z66aFLG1BmCj+eL7nVtTYt cK4gTiKlKqWn2yRcGWjW5LRqeAVVLqfkhhXsWNLiLBo9Zgq0+Kg6/vxNuY5LlkxS85Gb Ixcmqjk+tWvrRQjNR1hi9/Rw/XWlg/8sRe5b3ktZx2ejjrbn1zTtEicnGKE5x0rI82nV OkEjEpuapBse5Ma5nqzqPKSZG53yeRpOjG03BHTr13Qq4khy0SsLysLpet/qF+HitfBn 3b8MJ+T1GKIyK9RVAGRbyO17N7Wv0uyGH5ShDvpdZeFE2ihm+yr9lUMoWg5HgAQ4izjB iSow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=A2T2rxUxD8eUWcbZD2OueCG+9wKyZNMhcfP6onB/f8s=; b=ofo/EgpQnsUKIfnCuB1KqUlrqZGEWFXXgVfeU5J7GIF0OHnTcgKnrFESoUWyK93ZgR 7y2nPGEAwTDejmqe+OXTi9caJeAON9M9wBRwMEOcaWFK/4kS7uOOx39pGwH4q4u/OHO3 QEYi4h3R0BXnPeS9Sj3/V3VDaEfPgKTEkva1+UQeyPrZZIBatPUt37/R0akLexLlURYH DPEUmCsXIleDcU8mqhGv+4c9L/oxrvOc3UnIXdHpRFDk3umKp/WL7HYAFcs5D/AcgbQA n0mzrFpscDOhjEjaHTALzguNOQGZ+caYjUFfVk+/MlLFBrkIIZGXX75D8jQF5YWL5ZcI LBEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TPhMv4BM; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d20-20020a056402079400b005149e0f8897si2050197edy.331.2023.05.30.00.24.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 00:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TPhMv4BM; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 492BF3871586 for ; Tue, 30 May 2023 07:22:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 492BF3871586 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685431345; bh=A2T2rxUxD8eUWcbZD2OueCG+9wKyZNMhcfP6onB/f8s=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TPhMv4BM0wVpahx4DAcZsroIdHzoMC2DmlV7SSmwOEaZwQKmva8dt1ON6Kzt/rwer ysb+TqvUje2mjvoV//v9LRvi0gINfFwWhEyRSvd6ZO95YZMfqnDfA1RigHj6wgoWUB 5al/TZ6P0G3pyPqfjZPZyis0l4T05SS4lfuPiWhE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id C82BD3856243 for ; Tue, 30 May 2023 07:20:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C82BD3856243 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3094910b150so4091099f8f.0 for ; Tue, 30 May 2023 00:20:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685431237; x=1688023237; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A2T2rxUxD8eUWcbZD2OueCG+9wKyZNMhcfP6onB/f8s=; b=FYT8RmjnwUkAG2NfDIpC212F1fGfEi3rO3hthB7tUgBDbY+kKC1k2dRwhvgSy48w5k okvpuM2YeaX9KYZPNSar6hcql4/tvKjiNVp2aqleO2LlntwiDht6vlsnQXRiAdfF568h v65xVAwFKyH9w57xBeQupDKDoYZh1o7yRn4426vBG6GiGZ/CUDamrjWe5onAGrG8RPS6 8xvZyUNxXBWbzuY/v1JkZFRP0VcPA5K4I8POmbQD9+iJX6Jml4T+ryXUl2H+kw00b6+K yO4TlgZmtEyA8pWqoWZxkxSVBCcJ8gAympAlrJYJ1xT3daYLS2nFB0SLjaoATRj8j/Rb WpfQ== X-Gm-Message-State: AC+VfDwVWCoPjr+ky8YxHt71OLWq3AvMlHik5s8tCYJ0fr0Kl66FFOoK mfd8R8FZFiDrQp+jbCmfTORLblYAeHoygtTu3SAtNA== X-Received: by 2002:a5d:4902:0:b0:30a:d517:2359 with SMTP id x2-20020a5d4902000000b0030ad5172359mr738091wrq.64.1685431237701; Tue, 30 May 2023 00:20:37 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:7733:a608:a415:6b2a]) by smtp.gmail.com with ESMTPSA id u14-20020adfeb4e000000b003062b6a522bsm2197502wrn.96.2023.05.30.00.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 00:20:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Johannes Kliemann Subject: [COMMITTED] ada: Ensure Default_Stack_Size is greater than Minimum_Stack_Size Date: Tue, 30 May 2023 09:20:36 +0200 Message-Id: <20230530072036.2499750-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767302973076940052?= X-GMAIL-MSGID: =?utf-8?q?1767302973076940052?= From: Johannes Kliemann The Default_Stack_Size function does not check that the binder specified default stack size is greater than the minimum stack size for the runtime. This can result in tasks using default stack sizes less than the minimum stack size because the Adjust_Storage_Size only adjusts storages sizes for tasks that explicitly specify a storage size. To avoid this, the binder specified default stack size is round up to the minimum stack size if required. gcc/ada/ * libgnat/s-parame.adb: Check that Default_Stack_Size >= Minimum_Stack_size. * libgnat/s-parame__rtems.adb: Ditto. * libgnat/s-parame__vxworks.adb: Check that Default_Stack_Size >= Minimum_Stack_size and use the proper Minimum_Stack_Size if Stack_Check_Limits is enabled. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/libgnat/s-parame.adb | 2 ++ gcc/ada/libgnat/s-parame__rtems.adb | 2 ++ gcc/ada/libgnat/s-parame__vxworks.adb | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/ada/libgnat/s-parame.adb b/gcc/ada/libgnat/s-parame.adb index 930c92d35e2..6bd9f03f63f 100644 --- a/gcc/ada/libgnat/s-parame.adb +++ b/gcc/ada/libgnat/s-parame.adb @@ -58,6 +58,8 @@ package body System.Parameters is begin if Default_Stack_Size = -1 then return 2 * 1024 * 1024; + elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then + return Minimum_Stack_Size; else return Size_Type (Default_Stack_Size); end if; diff --git a/gcc/ada/libgnat/s-parame__rtems.adb b/gcc/ada/libgnat/s-parame__rtems.adb index 2f2e70b1796..1d51ae9ec04 100644 --- a/gcc/ada/libgnat/s-parame__rtems.adb +++ b/gcc/ada/libgnat/s-parame__rtems.adb @@ -63,6 +63,8 @@ package body System.Parameters is begin if Default_Stack_Size = -1 then return 32 * 1024; + elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then + return Minimum_Stack_Size; else return Size_Type (Default_Stack_Size); end if; diff --git a/gcc/ada/libgnat/s-parame__vxworks.adb b/gcc/ada/libgnat/s-parame__vxworks.adb index 8e0768e1e29..38fe0222622 100644 --- a/gcc/ada/libgnat/s-parame__vxworks.adb +++ b/gcc/ada/libgnat/s-parame__vxworks.adb @@ -58,11 +58,13 @@ package body System.Parameters is begin if Default_Stack_Size = -1 then if Stack_Check_Limits then - return 32 * 1024; -- Extra stack to allow for 12K exception area. + return 32 * 1024; else return 20 * 1024; end if; + elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then + return Minimum_Stack_Size; else return Size_Type (Default_Stack_Size); end if; @@ -74,7 +76,12 @@ package body System.Parameters is function Minimum_Stack_Size return Size_Type is begin - return 8 * 1024; + if Stack_Check_Limits then + -- Extra stack to allow for 12K exception area. + return 20 * 1024; + else + return 8 * 1024; + end if; end Minimum_Stack_Size; end System.Parameters;