Rate This Document
Findability
Accuracy
Completeness
Readability

Stack Overflow Caused by Unrolling the Nested Loop Too Many Times

The following is an example of a nested loop:

1
2
3
4
5
for (c = 0; c <= 36; c++) {
  a = 5;
  for (; a <= 42; a++)
    i = (h *= b *= 3) ? b |= 4 : (i %= 5) & 0;
}

When the default stack size of the host system is limited, a segmentation fault may occur.

The reason is that the inner and outer loops are unrolled. As a result, the form is too complex and stack overflow occurs in the analysis phase.

Workaround

Run the ulimit -s command to set the stack space size to a larger value. For example, run the ulimit -s 20000 command to set the upper limit of the stack size to 20000 KB, or run the ulimit -s unlimited command to set the stack size to unlimited.

You can run the ulimit -a command to view the default stack size limit of the system.