-1

Possible Duplicate:
What is a stack overflow error?

Well, I have heard its the most common error that one experiences while writing a program... I am very new to programming, just 2 years coding and I have never actually come across this error! So, at the risk of sounding very stupid, I would like to ask... What is stackoverflow and what is bufferoverflow?

Is stackoverflow somehow related to bufferoverflow?

A wiki link will literally not help me coz I have gone through it and am did not understand it. So if you could dumb it down.... How would you put it?

Community
  • 1
  • 1
traumatized
  • 123
  • 8
  • 2
    He is also asking about buffer overflows. – Oded Oct 11 '10 at 12:46
  • 4
    Note: this does *not* belong on meta as it's about "stack overflow" the runtime error, not "Stack Overflow" the web application. – ChrisF Oct 11 '10 at 12:46
  • 2
    Definitely not an exact duplicate! Edited the question.. Please vote to reopen! – traumatized Oct 11 '10 at 12:49
  • It's messy, because the two questions that you are asking have *both* already been asked and answered. If we were doing the close votes now, however, I would mark it as an *exact* duplicate of [What is the difference between a stack overflow and buffer overflow ?](http://stackoverflow.com/questions/1120575/what-is-the-difference-between-a-stack-overflow-and-buffer-overflow). – Matchu Oct 11 '10 at 12:54
  • 1
    I assume they have been answered as separate questions and not as a dumbed out comparison of the two.. I assumed this to be a unique question.. Unless you can give me a link for what I ask... Thanks – traumatized Oct 11 '10 at 12:57
  • @Matchu: that's what comments are for, I guess. The question adds nothing new to the site, closing sounds right. – Konerak Oct 11 '10 at 12:57
  • @Konerak please have a look at my last comment. – traumatized Oct 11 '10 at 12:59
  • 2
    Exact duplicate of http://stackoverflow.com/questions/1120575/what-is-the-difference-between-a-stack-overflow-and-buffer-overflow! Have a look at your linked question.. Its a combination of a couple of more questions that what you could individually surf the site to get... – Shouvik Oct 11 '10 at 13:03
  • @traumatized: please take a look at my edit – oezi Oct 11 '10 at 13:45

2 Answers2

6

Most operating system hold program information in data stuctures called a stack and a heap.

A StackOverflow occurs when one has added more information to the stack than it is allowed to hold (many times this can happen with a recursive function the doesn't have a termination clause).


A buffer is a set of memory locations (normally contiguous) that is used to hold temporary data. A buffer overflow occurs when trying to write into memory beyond the end of the buffer. This has security implications, as sometimes the memory beyond the buffer is not protected and code inserted after it may get executed.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
2

A StackOverflow is what happens when you run out of stack space for you programme to execute in.

I got one the other day with some poorly written event code, where one event would trigger another event causing the original event, and so on, until the stack overflowed with method calls.

A buffer overflow or buffer overrun is what happens when you try to write data past the end of an array. For example

char* s = "hello";
s[7] = 'g';

There is no knowing what writing 'g' to the location 7 in the string will do. This technique can be used by nefarious programmers to execute arbitrary code on a system.

Matt Ellen
  • 11,268
  • 4
  • 68
  • 90