Why are stackoverflow errors chaotic?

后端 未结 7 827
醉话见心
醉话见心 2021-01-12 11:29

This simple C program rarely terminates at the same call depth:

#include 
#include 

void recursive(unsigned int rec);

int ma         


        
7条回答
  •  迷失自我
    2021-01-12 12:11

    There is a gap between the stack segment and the heap segment. Now because the size of heap is variable( keeps on changing during execution), therefore the extent to which your stack will grow before stackoverflow occurs is also variable and this is the reason why your program rarely terminates at the same call depth.

    enter image description here

提交回复
热议问题