Faulthandler module allocating stack using malloc


in Modules/faulthandler.c, in the function faulthandler_allocate_stack, I see that the alternate stack for subsequent sigaltstack call is allocated via PyMem_Malloc.

    stack.ss_sp = PyMem_Malloc(stack.ss_size);
    if (stack.ss_sp == NULL) {
        return -1;

I think PyMem_Malloc is internally calling malloc, since heap space is unguarded and it is difficult to track overflow or underflow, can’t we use mmap instead? Why is heap space used here to begin with?