Possible reasons for segmentation fault on function exit
-
What possible reasons can you think of for a segmentation fault on exiting a function in C++? What I mean by that is, that I have a reproducible segmentation fault in a C++ program, and when I investigate using GDB is says Program received signal SIGSEGV, Segmentation fault. FooBar (bla=...) at foo.cpp:59 59 } where the indicated line contains the closing bracket of my function.
-
Answer:
There could be many reasons of this. Run program under Valgrind and most likely it will tell you exact reason or at least will help to investigate and narrow down the problem.
dcn at Stack Overflow Visit the source
Other answers
It's quite likely a http://en.wikipedia.org/wiki/Buffer_overrun on some buffer located on your stack. This overwrites the return address, so when your code tries to return to the previous stack frame, it instead jumps to some random address which is more likely than not non-executable, so you get a segmentation fault. But without seeing some more code or more information about the crash, it's impossible to say what the exact cause is.
Adam Rosenfield
My first guess is the destructor of a class is freeing an invalid pointer.
Rob K
Related Q & A:
- How to access a nested function from another nested function in javascript?Best solution by devarticles.com
- How do I exit a Chat room on Yahoo Messenger?Best solution by Yahoo! Answers
- Should graduates be issued an exit exam? Why or why not?Best solution by Yahoo! Answers
- What is geographic segmentation?Best solution by Stack Overflow
- Is this the American tourist's fault or the Chinese person's fault?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.