title: Infinite recursion in C
body: <p>Given the C program with infinite recursion:</p>
  
  <pre><code>int main() {
  
      main();
  
      return 0;
  }
  </code></pre>
  
  <p>Why would this result in a stack overflow. I know this results in undefined behaviour in C++ from the following thread <a href="https://stackoverflow.com/questions/5905155/is-this-infinite-recursion-ub">Is this infinite recursion UB?</a> (and as side node one can't call <code>main()</code> in C++). However, valgrind tells me this leads to a stack overflow:</p>
  
  <pre><code>Stack overflow in thread 1: can't grow stack to 0x7fe801ff8
  </code></pre>
  
  <p>and then finally the program ends due to a segmentation error:</p>
  
  <pre><code>==2907== Process terminating with default action of signal 11 (SIGSEGV)
  ==2907==  Access not within mapped region at address 0x7FE801FF0
  </code></pre>
  
  <p>Is this also undefined behavior in C, or should this really lead to a stack overflow and then why does this result in a stack overflow?</p>
  
  <p>edit</p>
  
  <p>1 I would like to know is infinite recursion allowed in C? <br>
  2 Should this result in a stack overflow? (has been sufficiently answered)</p>