https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865
--- Comment #11 from Bobby Lu <shaoqin2 at illinois dot edu> --- (In reply to Tim Shen from comment #9) > I see. Can you show the ulimit *stack* information? I believe it's -s. > > Also, try -O2 so that the functions are inlined. > > As for the stack overflow, it's a known issue. To workaround this, please > set a bigger stack size. $ ulimit -s unlimited -O2 resolves the issue. Thank you very much! So basically the issue can be explained as recursive call not being optimized out. Thus stack overflows is expected? This explains everything actually. I was trying to control so many different possible things and reproducing the bug. Removing random string parts would resolve it issue sometime, which now is just due to string is shorter thus stack needed is smaller?