我正在使用gdb调试一个程序,而我正在发生的事情正在发生。
几个小时工作正常后,程序卡住了,gdb显示以下信息。
(gdb) bt
#0 0xb7da8021 in write () from /lib/libc.so.6
#1 0xb7d5256f in _IO_file_write () from /lib/libc.so.6
#2 0xb7d52213 in ?? () from /lib/libc.so.6
#3 0xb7d524a6 in _IO_file_xsputn () from /lib/libc.so.6
#4 0xb7d2e31d in ?? () from /lib/libc.so.6
#5 0xb7d29b0e in vfprintf () from /lib/libc.so.6
#6 0xb7d3316f in fprintf () from /lib/libc.so.6
#7 0x080771b6 in print_screen (ws_row=63, ws_col=237, if_num=1) at server.c:8279
#8 0x0807196a in thread_one (arg=0x0) at server.c:5389
#9 0xb7e61f3b in start_thread () from /lib/libpthread.so.0
#10 0xb7db6d0e in clone () from /lib/libc.so.6
(gdb) frame 7
#7 0x080771b6 in print_screen (ws_row=63, ws_col=237, if_num=1) at server.c:8279
8279 fprintf(stderr, " %s", strbuf);
(gdb) p strbuf
$14 = " AKD3384HH", ' ' <repeats 139 times>, "\000", ' ' <repeats 106 times>, '\0' <repeats 255 times>
(gdb)
(gdb) p &strbuf
$15 = (char (*)[512]) 0xb54cee1c
(gdb) info registers
eax 0x6 6
ecx 0xb54cc280 -1253260672
edx 0x96 150
ebx 0x20 32
esp 0xb54ce980 0xb54ce980
ebp 0xb54cf058 0xb54cf058
esi 0x5a 90
edi 0x65 101
eip 0x80771b6 0x80771b6 <print_screen+5914>
eflags 0x200246 [ PF ZF IF ID ]
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x33 51
在函数print_screen中,我用(显然)有效的参数调用fprintf,并且不知何故,libc卡在写入系统调用中。 我不知道问题出在哪里,我只是用有效的字符串缓冲区编写stderr ..
我对这个问题很生气。任何帮助或线索将不胜感激!!
(请注意,此功能print_screen和fprintf调用在5小时内正常工作)