![]() |
|
#1
|
|||
|
|||
Error of *** stack smashing detected ***:hi all,
relatively new to c++. may i know how do i solve *** stack smashing detected *** error? i am actually runnning some open source software however when i upgrade to ubuntu 9.04, it seems to give me this error when i run the program. i did some research online, below is a site which i read about stack smashing, http://www.de-brauwer.be/wiki/wikka.php?wakka=StackSmash this is the first time i encouter, it had been running smooothly on ubuntu 8.10 and xubuntu 8.10.. i tried increasing the buffer size used in the cpp files it still did not work. i cant test the example given from the site above as the cpp files are being invoked by a perl script. please advise. |
|||
|
#2
|
|||
|
|||
Re: error of *** stack smashing detected ***:Quote:
The usual cause is writing outside the bounds of an array. Note that there may be other bugs that manifest themselves by generating this error message, but my experience is that this is the most common cause. See Footnote. Anyhow... The result of writing beyond the bounds of an array is "undefined behavior." Depending on other things in the program, "undefined behavior" may cause no apparent problems. It may cause an immediate program crash. The program might have overwritten other variables and the result would be a crash sometime later in the program when the corrupted variable's value was used somehow. Sometimes the program might actually run with no apparent problems, but crash with this message when the program exits. Bottom line: The behavior of a program with undefined behavior is, well, undefined. Quote:
Maybe the program us writing to an array using a negative array index. Maybe the program is using the value of an uninitialized variable value as an index to write to the array. Some compiler versions "helpfully" load all variables with zero values before starting up while some do not. Maybe the uninitialized variable value happens to be some verrrrrry large number, so that modest (or even immodest) increases in array sizes won't keep it from happening. Even if you could "fix" the problem by some band-aid like blindly increasing sizes of arrays, the program would still have a bug if it uses an uninitialized variable value as an array index. Bottom line, rev 2.0: The program has a bug. If you can't analyze it, then maybe you can contact the program's author with a bug report. (If you are using some unmodified open source program that is available on the internet, you could even tell us what it is and what you are doing with it.) Tell the author:
Regards, Dave Footnote: In general, because of (among other things) the possibility of undefined behavior, you can't "prove" a program is valid by testing alone. That is why it is very important to tell us exactly what the program was doing at the time of the crash. There are tools (valgrind, for example) that sometimes can give some information about invalid use of allocated memory. Or, maybe, not. Also using a debugger (gdb for example) can sometimes help isolate the problem area to let you know where to look for the bug. Or, maybe, not. Last edited by davekw7x : 16-Jun-2009 at 09:36.
|
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Test driver code for stack class | glacier | C++ Forum | 2 | 03-Oct-2008 04:14 |
| clean up suggestions | dabigmooish | C++ Forum | 4 | 17-Nov-2006 07:30 |
| prime factors with stack | Kubu | C++ Forum | 5 | 16-Apr-2006 18:08 |
| Help With Stacks | penance | C Programming Language | 9 | 10-Oct-2005 09:25 |
| infix to postfix | Kacyndra | C++ Forum | 2 | 15-Aug-2005 11:44 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The