Asus gates
Asus gates

Reputation: 408

Checking the reason for segmentation fault on Linux server

I have a Linux script written in C Language deployed at a remote server, to which multiple clients can connect. Due to some reason the script crashed and when I am trying to restart it I am getting segmentation fault.Is there any way by which I can Check at server side that what is stopping my script from starting, and is throwing segmentation fault error.

Upvotes: 1

Views: 3515

Answers (1)

Yam Marcovic
Yam Marcovic

Reputation: 8141

Start out by enabling core dumps:

$ ulimit -c unlimited

Now run the script until it segfaults. This will create a core dump file in your working directory.

Next, use GDB (or any frontend of it) to debug it (note that you can copy the file to your local machine if you can't debug on the server):

$ gdb -c <core_file>

Don't forget to add the symbol file:

GDB> file my-prog

If it's easy to reproduce the problem, and provided you can debug directly on the server (with SSH or such), you can simply dive in and start the process with a debugger attached:

$ gdb my-prog

Upvotes: 3

Related Questions