I am trying to debug a problem with an application on Linux. It tends to crash with SIGSEGV in random places at libstdc++.so or libstdc.so.
There seem to be no obvious race conditions anywhere, as the job in the thread I added is very isolated. But it still crashes almost all the time.
The application is compiled with g++ -c ... -pthread -D_REENTRANT, and linked with g++ -pthread -o ...
But it’s still crashing almost all the time in one of the libstdc*.so functions. I have wasted a few days on trying to figure out what’s wrong, but no go…
Does anyone have any tips? Is there a way to make sure libstdc*.so is compiled as thread aware? Any gdb commands that could help me? Debug heaps?
I’m working with Linux for only a few years, so I’m lost…
There are few things you should do :
Write unit tests. Although they do not help much in finding problems with threads, they can help you greatly with finding wrong memory access problems.