I am using scientific linux. In the directory

user/project/Build

, after I ran 'make' to compile and link all the cpp files,I had no problems. But then, when I went to directory

user/run/run.sh

, which runs the project binary in

user/project/Build/bin/project

, I get a segmentation fault error. In the directory user/run, I enter 'gdb' in the command prompt and get the message

*** No targets specified and no makefile found.  Stop.

I then set the size limit of core files by

ulimit -c 75000

But when I enter

gdb /user/project/Build/bin/project core

I get

gdb /user/project/Build/core: No such file or directory.

When I enter "bt", I get

No stack

When I then use the command prompt to go into directory

/user/project/Build/bin

and then type

gdb project

and then "run", I get

Thread debugging using libthread_db enabled.. Program exited with code 01.Missing separate debuginfos, 
use: debuginfo-install glibc-2.12-1.149.el6_6.4.x86_64 libICE-1.0.6-1.el6.x86_64 .

What am I supposed to do to detect the segmentation fault?

Recommended Answers

All 4 Replies

First of all, you have to make sure that you compiled the project with debugging symbols enabled. How you do that would depend on the project itself and the way it has its makefiles setup.

Then, to trace back the origin of segmentation faults, gdb is not a good tool for that. The standard tool for this type of debugging is Valgrind with the memcheck tool. When you have debugging symbols enabled and all that, you'll get a nice line-by-line trace-back of where the segmentation fault came from.

What happens if you run the actual binary using gdb? So don't start it with a shell script. Just run the binary.

gdb <binary executable>

and then

run

What happens if you run the actual binary using gdb? So don't start it with a shell script. Just run the binary.

gdb <binary executable>

and then

run

I get the message

Program exited with code 01.Missing separate debuginfos,
use: debuginfo-install glibc-2.12-1.149.el6_6.4.x86_64 libICE-1.0.6-1.el6.x86_64 .

As for valgrind,

The standard tool for this type of debugging is Valgrind with the memcheck tool.

I went to the directory "/user/project/Build/bin/" and just tried to enter

valgrind --tool=memcheck --leak-check=yes ./Project

but then got an error summary saying there's no errors. THis can't be right

That's not a segfault, then. That's the program running, and finishing, and the value the programme returned to the OS is 1.

Are there any command line parameters that should be passed to the binary as it's run? If you can't reliably produce the segFault, fixing it is going to be difficult.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.