From patchwork Sat Jul 10 18:10:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 44308 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 733EF3855016 for ; Sat, 10 Jul 2021 18:11:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 733EF3855016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625940693; bh=hXROl8mumKWe/tygT+Dkv92GFj+DMWvWD4bVGVjbY7k=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WCMC/Fdg+LTYwU+LE/grvALCDTuw7MIptUlsmyWjYPbfjPgM1tLHlGfNlAzhcZAoa 24k1ZSx5z9ynamUyWXswV5sCnrMG0lYpCpmmRPh/aGeVfjZaldxznl/w4mzgXF/lo0 vKXvmGFdJ6wy2ZDXWWiWlsO1aKKJjodJ+NEq2/2s= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 75E29385783D for ; Sat, 10 Jul 2021 18:11:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 75E29385783D Received: by mail-pj1-x1031.google.com with SMTP id p4-20020a17090a9304b029016f3020d867so7936778pjo.3 for ; Sat, 10 Jul 2021 11:11:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hXROl8mumKWe/tygT+Dkv92GFj+DMWvWD4bVGVjbY7k=; b=tRUmOsOXhLvTYUtYKOtd8LWYnjNU7Z/JNeGLo2vOFWFJCbctzAKeaQXoWnZsV/QieQ v+Q3EHXnHKtUl6IwuYwhLKjYWARS5ItIioG2ccKsDCSNs0GvC/VBT9JfDSdlLBXjdKI7 Sc3LEPmmx6UhgY/RvLbIQYlF/V1bie6bndwyXLiGUPgAOsH8AX3XG3pbfLcGbA7jv+3s UMz89UBJwNLCSjzVb0ijJ4TUDIDZKT/DCJ9xKp3JRHfb6Uy/hfvw7vNQhAnsEBFNWNZu r/hUHyS1WHeJB7UXB75jc9rO8Z8k/BF1IVqs5qcCIWuDi/JMDS9D+1Ga4f3fNsNXcREK HkWA== X-Gm-Message-State: AOAM532ICzQGNbyxrJoSXaSXrK37YOeuhR2MjBh0qYR024HWaxVM3gX9 1JQCOksfnulEwCQZ3IgDQujZ/Res6t57Bqc7VZQ= X-Google-Smtp-Source: ABdhPJxHCXLSuBqs1/+xPJJk5R28sZfP1t4aHqbaXpwxuHAkAlJ4yfp12j9j3OMx+e4FZFXL6ci71bXTEpT/uXs0/Yc= X-Received: by 2002:a17:90b:3607:: with SMTP id ml7mr5409185pjb.153.1625940668551; Sat, 10 Jul 2021 11:11:08 -0700 (PDT) MIME-Version: 1.0 References: <20210709213831.1477694-1-hjl.tools@gmail.com> In-Reply-To: Date: Sat, 10 Jul 2021 11:10:32 -0700 Message-ID: Subject: [PATCH] support: Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZ To: "Carlos O'Donell" X-Spam-Status: No, score=-3031.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: GNU C Library Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" On Fri, Jul 9, 2021 at 3:10 PM Carlos O'Donell wrote: > > On 7/9/21 5:38 PM, H.J. Lu via Libc-alpha wrote: > > Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ) since the constant > > MINSIGSTKSZ used in glibc build may be too small. > > LGTM. It's good to explicitly convert to using sysconf in support/* code. I used the wrong _SC_XXX. _SC_MINSIGSTKSZ is for the empty signal handler. sysconf (_SC_SIGSTKSZ) returns the suggested minimum number of bytes of stack space required for a signal stack. OK for master? > Reviewed-by: Carlos O'Donell > > > --- > > support/support_stack_alloc.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/support/support_stack_alloc.c b/support/support_stack_alloc.c > > index 03494dd185..b05ae08968 100644 > > --- a/support/support_stack_alloc.c > > +++ b/support/support_stack_alloc.c > > @@ -39,10 +39,11 @@ support_stack_alloc (size_t size) > > if (pagesize == -1) > > FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n"); > > > > - /* Always supply at least MINSIGSTKSZ space; passing 0 as size means > > - only that much space. No matter what the number is, round it up > > - to a whole number of pages. */ > > - size_t stacksize = roundup (size + MINSIGSTKSZ, pagesize); > > + /* Always supply at least sysconf (_SC_MINSIGSTKSZ) space; passing 0 > > + as size means only that much space. No matter what the number is, > > + round it up to a whole number of pages. */ > > + size_t stacksize = roundup (size + sysconf (_SC_MINSIGSTKSZ), > > + pagesize); > > > > /* The guard bands need to be large enough to intercept offset > > accesses from a stack address that might otherwise hit another > > > > > -- > Cheers, > Carlos. > Reviewed-by: Carlos O'Donell From 1b30a2708f2bc8a7161c19737ac5f5927803ffc9 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 10 Jul 2021 10:56:50 -0700 Subject: [PATCH] support: Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZ Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZ since sysconf (_SC_MINSIGSTKSZ) returns the minimum number of bytes of free stack space required in order to guarantee successful, non-nested handling of a single signal whose handler is an empty function while sysconf (_SC_SIGSTKSZ) returns the suggested minimum number of bytes of stack space required for a signal stack. --- support/support_stack_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support/support_stack_alloc.c b/support/support_stack_alloc.c index b05ae08968..62eee84573 100644 --- a/support/support_stack_alloc.c +++ b/support/support_stack_alloc.c @@ -39,10 +39,10 @@ support_stack_alloc (size_t size) if (pagesize == -1) FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n"); - /* Always supply at least sysconf (_SC_MINSIGSTKSZ) space; passing 0 + /* Always supply at least sysconf (_SC_SIGSTKSZ) space; passing 0 as size means only that much space. No matter what the number is, round it up to a whole number of pages. */ - size_t stacksize = roundup (size + sysconf (_SC_MINSIGSTKSZ), + size_t stacksize = roundup (size + sysconf (_SC_SIGSTKSZ), pagesize); /* The guard bands need to be large enough to intercept offset -- 2.31.1