How to deal with segmentation error with GDB in certain circumstances?

I wrote a program on Linux to handle a lot of data. In most cases, it worked fine, but when I completed the task, I encountered a segmentation error error. Because the program works fine with other data, so I do not know how to deal with this problem. And by the way, how to get the value of a variable with segfault?

here is the output of gdb:

Program received signal SIGSEGV, Segmentation fault. tyn_p4d_encode32 (in=0x10000000c01, cnt_in=118248, out=0x10000000101 <Address 0x10000000101 out of bounds>, add_termination=1) at tyn_coder.c:645 645 length_stat[count_bits32(*(in + i)) - 1]++; Missing separate debuginfos, use: debuginfo-install glibc-2.14.90-24.fc16.6.x86_64 zlib-1.2.5-5.fc16.x86_64 (gdb) bt #0 tyn_p4d_encode32 (in=0x10000000c01, cnt_in=118248, out=0x10000000101 <Address 0x10000000101 out of bounds>, add_termination=1) at tyn_coder.c:645 #1 0x0000000000404582 in nodes_term32_flush (array=<optimized out>, size=<optimized out>, nodes_context=0x2ded020, is_last=0) at tyn_indexer.c:116 #2 0x0000000000407b78 in tyn_exsorter_sort (exsorter=0x64c4a0, context=0x2ded020, nodes_flush=0x404320 <nodes_term32_flush>, progress_callback=0x404190 <progress_callback>) at tyn_exsorter.c:131 #3 0x0000000000406ddf in tyn_build_index (tyn_config=0x61a060, index_name=0x4138d1 "mysql_index") at tyn_indexer.c:731 #4 0x0000000000403850 in main (argc=<optimized out>, argv=<optimized out>) at tyn_indexer.c:943 
+1
source share
2 answers

You need to compile and link the -g flag to be able to use the debugger; but you seem to be doing it already. print (abbreviated p ) prints the value of a variable; bt , up , down , frame are other useful commands. Otherwise, help within gdb or info gdb .

+1
source

In this case, you can use coredump. First of all, enable coredumps ulimit -c unlimited ... using gdb, like this gdb <path to executable> <path to coredump> ... this coredump will contain the values โ€‹โ€‹of variables and frames during segfault, etc. Intact .... so you can use this information for debugging purposes.

+1
source

Source: https://habr.com/ru/post/1403015/


All Articles