https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97717
--- Comment #3 from Rahul Kranti Kiran <kranti.rkiran at gmail dot com> --- The stack size was 8 KB and 'ulimit -s unlimited' worked for root but gets reset as soon as I got back to the userspace. Running the compilation with unlimited stack still threw a SEGFAULT. The complete output of ulimit -a, when running as a root. core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7823 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65536 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 7823 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited Yes, the compilation was just using -O3 flag. Apologies for the delayed reply.