(This is the older material - click here - for current specification content)

13. Problem 4: Stack Overflow

The diagram below shows the internal structure of a segment which you have seen in earlier pages.

A program segment

 

But do you see a potential problem?

Notice the Stack can grow down towards the data segment. It grows because every time a function calls another function, the address of the first is stored in the stack along with any parameters it uses. But what if the new function now calls another? and that one calls yet another? A poorly written or faulty program will cause the stack to 'overflow'.

A stack overflow means the stack has either intruded into the data segment, or it has reached its maximum allowed size. Either way, the program will usually crash at this point, possibly with a 'stack overflow' error message on screen.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Stack Overflow

 

Copyright © www.teach-ict.com