I thought I'd share a little tidbit I just learned, just so no one else tears their hair out like me in the future.
I was writing a program, and I had a function that returned a string. I didn't realize that I'd forgotten the return statement, and unfortunately I wasn't compiling with -Wall, which would have shown me that. Anyway, I was getting a segfault and bad permissions error, like this:
==25217== Process terminating with default action of signal 11 (SIGSEGV) ==25217== Bad permissions for mapped region at address 0x80F2B61 ==25217== at 0x40B5C1B: std::string::~string() (in /usr/lib/libstdc++.so.6.0.10) ==25217== by 0x804ACD8: MyCode::run() (MyCode.cpp:219) ==25217== by 0x804BD28: main (MyCode.cpp:243)
And whenever I looked in the code I wrote, the line numbers corresponded to the method signatures, but no particular line in the method I could debug from.
So what did I learn from this? ALWAYS, ALWAYS check to make sure you have appropriate return statements. If a lack of return statements was an error in g++, rather than a warning, I bet it would save people a lot of debugging headaches.
The takeaway message from this is, if you get segfaults that map back to method signatures, check the return statements first. It'll save you a lot of hassle.
Hope that helps someone!