c - I can print the memory with gdb's x command ,but if I use printf,segmentation fault -


this line causing segfault me:

30              printf("st_name:\t%s\n", &p_str_tab[p->st_name]); 

i've tried trace down in gdb:

(gdb) p p_str_tab[p->st_name] $11 = 0 '\000' (gdb) p &p_str_tab[p->st_name] $12 = 0x2aaaaaab0000 "" (gdb) x/16s 0x2aaaaaab0000 0x2aaaaaab0000:  "" 0x2aaaaaab0001:  ".symtab" 0x2aaaaaab0009:  ".strtab" (gdb) call printf("st_name:\t%s\n", 0x2aaaaaab0000)  program received signal sigsegv, segmentation fault. 0x00000034f4042729 in vfprintf () /lib64/libc.so.6 program being debugged signaled while in function called gdb. gdb remains in frame signal received. change behavior use "set unwindonsignal on". evaluation of expression containing function 

i can print memory gdb's x command ,but if use printf,segmentation fault.

why?

update required in comment:

(gdb) x/1i $rip  0x34f4042729 <vfprintf+57>: mov    0xc0(%rdi),%eax (gdb) info reg  rax            0x54 84 rbx            0x34f3e1bbc0 227429956544 rcx            0x0  0 rdx            0xffffffffffffffb0   -80 rsi            0x401b08 4201224 rdi            0x600908 6293768 rbp            0x7fffffffe6e0   0x7fffffffe6e0 rsp            0x7fffffffe040   0x7fffffffe040 r8             0x2aaaaaabf210   46912496202256 r9             0x34f4351780 227435419520 r10            0x1238   4664 r11            0x648    1608 r12            0x0  0 r13            0x7fffffffe9c0   140737488349632 r14            0x0  0 r15            0x0  0 rip            0x34f4042729 0x34f4042729 <vfprintf+57> eflags         0x10202  [ if rf ] cs             0x33 51 ss             0x2b 43 ds             0x0  0 es             0x0  0 fs             0x0  0 gs             0x0  0 fctrl          0x37f    895 fstat          0x0  0 ftag           0xffff   65535 ---type <return> continue, or q <return> quit--- fiseg          0x0  0 fioff          0x0  0 foseg          0x0  0 fooff          0x0  0 fop            0x0  0 mxcsr          0x1f80   [ im dm zm om um pm ] 

must pointer overran issue ,try valgrind.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -