support: Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ)

Message ID 20210709213831.1477694-1-hjl.tools@gmail.com
State Committed
Commit 28d07380c2ae5786e242be336ccc1c9e3111f3fa
Headers
Series support: Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ) |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

H.J. Lu July 9, 2021, 9:38 p.m. UTC
  Replace MINSIGSTKSZ with sysconf (_SC_MINSIGSTKSZ) since the constant
MINSIGSTKSZ used in glibc build may be too small.
---
 support/support_stack_alloc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Comments

Carlos O'Donell July 9, 2021, 10:10 p.m. UTC | #1
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.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  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
>
  

Patch

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