我將從proc *代碼從UNIX移植到LINUX。這些代碼已成功編譯並創建可執行文件。但在運行期間,它會引發分段錯誤。我一步一步地調試代碼,下面是GDB調試的輸出。strftime_l的SIGSEGV分段錯誤lib64/libc.so.6
Breakpoint 4 at 0x3b19690f50
(gdb) n
525 strftime (buf, MAX_STRING_LEN, "%d/%b/%Y:%H:%M:%S", dummy_time);
(gdb) n
Breakpoint 4, 0x0000003b19690f50 in strftime() from /lib64/libc.so.6
(gdb) n
Single stepping until exit from function strftime,
which has no line number information.
0x0000003b19690f70 in strftime_l() from /lib64/libc.so.6
(gdb) n
Single stepping until exit from function strftime_l,
which has no line number information.
Program received signal SIGSEGV, Segmentation fault.
0x0000003b19690f8b in strftime_l() from /lib64/libc.so.6
其實在代碼中函數strftime()
被調用。但我不知道它爲什麼會在/lib64/libc.so.6中達到strftime_l()
。
此問題不在UNIX中提供。請幫忙。代碼是
static void speed_hack_libs(void)
{
time_t dummy_time_t = time(NULL);
struct tm *dummy_time = localtime (&dummy_time_t);
struct tm *other_dummy_time = gmtime (&dummy_time_t);
char buf[MAX_STRING_LEN];
strftime (buf, MAX_STRING_LEN, "%d/%b/%Y:%H:%M:%S", dummy_time);
}
請通過編輯將代碼添加到您的問題。 – dwalter
更好地更新標題! Nevermind Linux是一個Unix(類似系統)... – 2012-05-15 11:12:35
MAX_STRING_LEN的價值是什麼? –