Add/uncomment to /etc/security/limits.conf

*       soft    core    unlimited
*       hard    core    unlimited
root       soft    core    unlimited
root       hard    core    unlimited

Add to /etc/sysctl.conf

kernel.core_pattern = /var/coredumps/core-%e-%s-%u-%g-%p-%t
kernel.core_uses_pid = 1
fs.suid_dumpable = 2

Create /var/coredumps/

Edit /etc/systemd/system.conf

DefaultLimitCORE=infinity

Run

sysctl -p
ulimit -c unlimited
systemctl daemon-reexec

Restart all needed services

For testing create file test.c

int a (int *p) {
    int y = *p;
    return y;
}
 
int main (void) {
    int *p = 0; /* null pointer */
    return a (p);
}

Compile and run

gcc -o test test.c && ./test