tags:

views:

86

answers:

2

Program received signal SIGSEGV, Segmentation fault. 0x08049795 in execute_jobs () Current language: auto; currently asm

(gdb) info symbol 0x08049795 execute_jobs + 22 in section .text

(gdb) ptype 0x08049795 type = int

How to get the line number at which the error occurred?

+2  A: 

The gdb command "bt" will show you a back trace. Unless you've corrupted the stack this should show the sequence of function calls that lead to the segfault. To get more meaningful information make sure that you've compiled your program with debug information by including -g on the gcc/g++ command line.

torak
thanks. I dint know that.
blacktooth
Program received signal SIGSEGV, Segmentation fault.0x0804ae2a in job_comparator_randomjobid (element1=0x804d0c0, element2=0x804d60c) at ./machinejob.c:860860 JOB job1 = *((JOB*) element1);(gdb) info symbol 0x0804ae2ajob_comparator_randomjobid + 20 in section .textWhat's 20 above?
blacktooth
+6  A: 

Your binary was not compiled with debugging information. Rebuild with at least -g (or -ggdb, or -ggdb -g3, see GCC manual.)

The exact lines from GDB output:

(gdb) info symbol 0x08049795 execute_jobs + 22 in section .text

means that instruction at address 0x08049795, which is 22 bytes from beginning of function execute_jobs, generated the segmentation fault.

(gdb) ptype 0x08049795 type = int

Here you are asking for type of an integer, and GDB happily replies. Do

(gdb) x/10i 0x08049795

or

(gdb) disassemble execute_jobs

to see actual instructions.

Nikolai N Fetissov
Program received signal SIGSEGV, Segmentation fault.0x0804ae71 in job_comparator_randomjobid (element1=0x804d0c0, element2=0x804d354) at ./machinejob.c:860860 JOB job1 = *((JOB*) element1);How to determine the exact error that caused segmentation fault?
blacktooth
@blacktooth, you have to show code from `machinejob.c` around line 860 for us to be able to help you. `JOB` is what? A pointer? What's the type of `element1`? The root cause is an invalid address somewhere.
Nikolai N Fetissov