Background
While moving to a newer version of CC compiler, a segfault manifested in a module that used to work.
Observations so far
From the core file I could learn in what function the segfault originated. When I observed the function I could not find anything suspicious.
First major problem was that the segfault reproduced only when compiling in "release" (optimizations turned on), and didn't reproduce on "debug". Also, the segfault doesn't reproduce on g++.
Now I started to use printing, and a bigger problem arose- when adding
cout
/printf
(to binary search the segfault line/print the value of pointers) to certain lines in the code, the segfault didn't reproduce. Moreover, I added a cout in a certain line in the code that maintained the segfault, which supposedly means that the segfault happens before that line. Commenting lines after that line made the segfault go away.
To me, this screams memory corruption (specifically of the stack), but I have no idea on how to advance on this without looking at the generated assembly.
Any ideas? thanks in advance.
I'm working on SunOS_5.10_Studio_12_5.12_64, CC version "Sun C++ 5.12 SunOS_sparc 2011/11/16"
More details in response to comments
- The code is single-threaded.
- valgrind is not available on Solaris so it's not relevant.