2012-08-01 34 views
0

我正在使用Solaris 10,並且我的C程序崩潰並創建了一個核心文件。在調試時,似乎核心是在libc.so.1中創建的。請讓我知道是否有人有任何線索。 以下是dbx報告。libc.so.1中的核心

dbx prock.new core 
For information about new features see `help changes' 
To remove this message, put `dbxenv suppress_startup_message 7.6' in your .dbxrc 
Reading prock.new 
core file header read successfully 
Reading ld.so.1 
Reading libsocket.so.1 
Reading libnsl.so.1 
Reading libl.so.1 
Reading libpthread.so.1 
Reading librt.so.1 
Reading libthread.so.1 
Reading libc.so.1 
Reading libaio.so.1 
Reading libmd.so.1 
Reading libc_psr.so.1 
WARNING!! 
A loadobject was found with an unexpected checksum value. 
See `help core mismatch' for details, and run `proc -map' 
to see what checksum values were expected and found. 
dbx: warning: Some symbolic information might be incorrect. 
[email protected] ([email protected]) terminated by signal SEGV (no mapping at the fault address) 
0xffffffff7ea3bc14: strcasecmp+0x0134: orn  %i0, %i3, %i0 
(dbx) where 
=>[1] strcasecmp(0x10014b68e, 0x57, 0x7ffffc00, 0x1001332d7, 0x27, 0x24), at 0xffffffff7ea3bc14 
    [2] 0x10000af48(0x27, 0x10014b68e, 0x57, 0x10014b68e, 0x57, 0x0), at 0x10000af48 
    [3] 0x100009c08(0x27, 0x5e, 0x0, 0x9, 0x1001332c3, 0x2b), at 0x100009c08 

(dbx) whereis strcasecmp 
function:  `libc.so.1`strcasecmp 
(dbx) 

我的Solaris版本是

   Solaris 10 8/07 s10s_u4wos_12b SPARC 
    Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. 
       Use is subject to license terms. 
        Assembled 16 August 2007 
+0

看起來像你傳遞給strcasecmp的參數是不正確的(破壞或字符串不是NULL終止等) – Jay 2012-08-01 13:52:18

回答

2

沒有,這個問題是不是與C標準庫。您正在向strcasecmp()傳遞無效參數(NULL字符串指針等)。沒有實際的代碼(你沒有發佈),不可能推斷出錯誤是什麼。

(!還有,你最好編譯調試符號程序 - 與優化關閉。如果你是在Solaris上,你最有可能使用GCC:

gcc -O0 -g etc... 

+0

是的,這也是我的觀點。 C庫應該沒有問題。 – 2012-08-01 14:02:26

1

1)你的編譯方案中包括調試信息(加上「-g」,以選項的列表,你的編譯器),讓你真正得到的信息,而不是這樣的:

[2] 0x10000af48(0x27, 0x10014b68e, 0x57, 0x10014b68e, 0x57, 0x0), at 0x10000af48 
[3] 0x100009c08(0x27, 0x5e, 0x0, 0x9, 0x1001332c3, 0x2b), at 0x100009c08 

2)DBX會告訴你現在Wh是你的職能已經在致電strcasecmp。逐步通過源代碼(或者讓它生成日誌輸出),檢查致命函數調用的參數是否與任何異常(如無效指針)相同。

與您對該函數的調用出錯的機會相比,您發現libc函數中的錯誤的機會是微不足道的。

+0

謝謝DevSolar,我會添加更多的調試選項,並會回來。 – 2012-08-01 14:05:53

0

1)運行BT(回溯),看看誰在呼喚strcasecmp [這將列出如#0幀,#1]

2)現在跳起來到特定的幀獲取值[幀0]

3)然後顯示/打印傳遞給strcasecmp(使用打印或顯示參數)

我覺得爭論是關於調用strcasecmp NULL值,這就是爲什麼你得到段錯誤。