https://rethinkdb.com/blog/handling-stack-overflow-on-custom-stacks/

https://barrgroup.com/embedded-systems/how-to/prevent-detect-stack-overflow 

etc.
{
                    void * hint = reinterpret_cast<void *>(
                        std::uniform_int_distribution<intptr_t>(0x100000000000UL, 0x700000000000UL)(thread_local_rng));
                    void * map = mmap(hint, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
                    if (MAP_FAILED == map)
                        throwFromErrno("Allocator: Cannot mmap", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
                    maps.push_back(map);
                }
            }
            else
                throw Exception("Unknown trap mode", ErrorCodes::BAD_ARGUMENTS);
        }
        else
            throw Exception("The only argument for function " + getName() + " must be constant String", ErrorCodes::ILLEGAL_COLUMN);
        columns[result].column = columns[result].type->createColumnConst(input_rows_count, 0ULL);
    }
};
void registerFunctionTrap(FunctionFactory & factory)
{
    factory.registerFunction<FunctionTrap>();
}
}
#else
namespace DB
{
    class FunctionFactory;
    void registerFunctionTrap(FunctionFactory &) {}
}
#endif