This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Tests for minimal signal handler functionality in MINSIGSTKSZ space.
- From: Richard Henderson <rth at twiddle dot net>
- To: Zack Weinberg <zackw at panix dot com>, libc-alpha at sourceware dot org
- Cc: carlos at redhat dot com
- Date: Thu, 17 Jan 2019 09:41:12 +1100
- Subject: Re: [PATCH] Tests for minimal signal handler functionality in MINSIGSTKSZ space.
- References: <20190115200526.4677-1-zackw@panix.com>
On 1/16/19 7:05 AM, Zack Weinberg wrote:
> +xalloc_sigstack (size_t size)
> +{
> + size_t pagesize = sysconf (_SC_PAGESIZE);
> + if (pagesize == -1)
> + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n");
> +
> + size_t stacksize = roundup (size + MINSIGSTKSZ, pagesize);
...
> + desc->alt_stack.ss_sp = desc->alloc_base + guardsize;
> + desc->alt_stack.ss_flags = 0;
> + desc->alt_stack.ss_size = stacksize;
While I understand that the actual allocation from the system must round up to
pages, why do you want to round up the amount as seen by ss_{sp,size}?
It seems to me that if you really want to test MINSIGSTKSZ, then you should do
exactly that. E.g.
desc->alt_stack.ss_size = size;
if (_STACK_GROWS_DOWN)
desc->alt_stack.ss_sp = desc->alloc_base + guardsize;
else
desc->alt_stack.ss_sp = desc->alloc_base + guardsize + stacksize - size;
r~