Hi,
is there an implicit maximum size (besides the size_t data type of
course) of the ss_size field in the sigaltstack struct when using
sigaltstack()? E.g., following example based on `man 2 sigaltstack`
---8<--------------------------------------------------------------------------
#include <sys/mman.h>
#include <signal.h>
#include <stdio.h>
#define R_USAGE 1
static struct sigaltstack sigstk;
int main(int argc, char *argv[])
{
if ((sigstk.ss_sp = mmap(NULL, SIGSTKSIZE + R_USAGE, PROT_WRITE |
PROT_READ,
MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0)) == MAP_FAILED) {
perror("mmap");
}
sigstk.ss_size = SIGSTKSIZE + R_USAGE;
sigstk.ss_flags = 0;
if (sigaltstack(&sigstk, 0) == -1)
perror("sigaltstack");
return 0;
}
---8<--------------------------------------------------------------------------
works for R_USAGE == 0 but seems to fail for > 0 values (with "sigaltstack:
Invalid argument").
It is a pattern observed in math/R
(https://github.com/wch/r-source/blob/trunk/src/main/main.c#L641-L654) which
worked with malloc() but stopped working when switching to mmap() with
MAP_STACK.
Ideas? Comments?
Thank you.
Best regards,
Ingo