[PATCH] support: Replace _SC_MINSIGSTKSZ with _SC_SIGSTKSZ

H.J. Lu hjl.tools@gmail.com
Sat Jul 10 18:10:32 GMT 2021


On Fri, Jul 9, 2021 at 3:10 PM Carlos O'Donell <carlos@redhat.com> 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 <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
> >
>
>
> --
> Cheers,
> Carlos.
>


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-support-Replace-_SC_MINSIGSTKSZ-with-_SC_SIGSTKSZ.patch
Type: text/x-patch
Size: 1480 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20210710/a205a45b/attachment.bin>


More information about the Libc-alpha mailing list