我在linux上編寫了一個C程序來處理大量的數據。在大多數情況下似乎工作正常,但是在做工作時遇到了分段錯誤錯誤。因爲該程序與其他數據一起工作正常,所以我不知道如何處理這個問題。順便說一下,如何在段錯誤發生時檢索變量值?如何在特定情況下處理GDB的分段錯誤?
這裏是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 = <優化出來>'如何使這個沒有優化出來? – 2012-03-22 16:29:21
@MickeyShine您必須進行編譯而不進行優化。 – zvrba 2012-03-22 16:50:52