2014-11-24 34 views
-3

下活動env的程序,有段時間分段錯誤,我嘗試gdb的coredump文件,但是找不到導致coredump的代碼行。coredump at __correctly_grouped_prefixwc

Program terminated with signal 11, Segmentation fault. 
#0 0x00000038f3a41bf5 in __correctly_grouped_prefixwc() from /lib64/libc.so.6 
(gdb) bt 
#0 0x00000038f3a41bf5 in __correctly_grouped_prefixwc() from /lib64/libc.so.6 
#1 0x0000000000000000 in ??() 
(gdb) info r 
rax   0x1ac1b108  448901384 
rbx   0x2add423b4ff0 47129787322352 
rcx   0x2add48128640 47129885312576 
rdx   0x0  0 
rsi   0x1  1 
rdi   0x2add48000020 47129884098592 
rbp   0x2add3f1aef50 0x2add3f1aef50 
rsp   0x2add423b4ff0 0x2add423b4ff0 
r8    0x2  2 
r9    0x2  2 
r10   0x0  0 
r11   0x0  0 
r12   0x0  0 
r13   0x3  3 
r14   0x1000 4096 
r15   0x2add3f1b0000 47129734873088 
rip   0x38f3a41bf5  0x38f3a41bf5 <__correctly_grouped_prefixwc+165> 
eflags   0x10246 [ PF ZF IF RF ] 
cs    0x33  51 
ss    0x2b  43 
ds    0x0  0 
es    0x0  0 
fs    0x0  0 
gs    0x0  0 
fctrl   0x37f 895 
fstat   0x0  0 
ftag   0xffff 65535 
fiseg   0x0  0 
fioff   0xc54f06 12930822 
foseg   0x2add 10973 
fooff   0x423b3f00  1111179008 
fop   0x0  0 
mxcsr   0x1fa1 [ IE PE IM DM ZM OM UM PM ] 


cat /etc/redhat-release 
CentOS release 5.5 (Final) 

,我想在源代碼級調試的glibc,運行yum install yum-utils安裝debuginfo軟安裝程序。 然後運行sudo debuginfo-install glibc,結果如下

Loaded plugins: fastestmirror 
Loading mirror speeds from cached hostfile 
* addons: centos.ustc.edu.cn 
* base: mirror.bit.edu.cn 
* extras: centos.ustc.edu.cn 
* updates: centos.ustc.edu.cn 
Checking for new repos for mirrors 
Could not find debuginfo for main pkg: glibc-2.5-123.x86_64 
Could not find debuginfo for main pkg: glibc-2.5-123.i686 
No debuginfo packages available to install 

,然後我嘗試運行yum search glibc-debuginfo

Loaded plugins: fastestmirror 
Loading mirror speeds from cached hostfile 
* addons: centos.ustc.edu.cn 
* base: mirrors.163.com 
* extras: centos.ustc.edu.cn 
* updates: centos.ustc.edu.cn 
Warning: No matches found for: glibc-debuginfo 
No Matches found 

再沒有發現匹配。

我嘗試運行yum search glibc

Loaded plugins: fastestmirror 
Loading mirror speeds from cached hostfile 
* addons: centos.ustc.edu.cn 
* base: mirrors.163.com 
* extras: centos.ustc.edu.cn 
* updates: centos.ustc.edu.cn 
================================================================================ Matched: glibc ================================================================================= 
compat-glibc.i386 : Compatibility C library 
compat-glibc.x86_64 : Compatibility C library 
compat-glibc-headers.x86_64 : Header files for development using standard C libraries. 
glibc.i686 : The GNU libc libraries. 
glibc.x86_64 : The GNU libc libraries. 
glibc-common.x86_64 : Common binaries and locale data for glibc 
glibc-devel.i386 : Object files for development using standard C libraries. 
glibc-devel.x86_64 : Object files for development using standard C libraries. 
glibc-headers.x86_64 : Header files for development using standard C libraries. 
glibc-utils.x86_64 : Development utilities from GNU C library 
kernel-headers.x86_64 : Header files for the Linux kernel for use by glibc 
nss_db.i386 : An NSS library for the Berkeley DB. 
nss_db.x86_64 : An NSS library for the Berkeley DB. 
yp-tools.x86_64 : NIS (or YP) client programs. 
yum-protect-packages.noarch : Yum plugin to prevents Yum from removing itself and other protected packages 

我嘗試運行sudo yum install glibc-devel.x86_64,並再次用gdb的核心轉儲文件, 但它顯示以下

Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done. 
Loaded symbols for /lib64/libc.so.6 

我怎麼能找到的代碼行的原因核心轉儲?我嘗試谷歌,但沒有找到任何想法?

+0

我們確切的問題是什麼? – tristan 2014-11-24 02:29:44

+0

_「任何想法?」 - 使用調試器。 – 2014-11-24 02:39:17

+0

我如何找到代碼行導致coredump? – Sleepwom 2014-11-24 02:47:09

回答

1

首先,儘管__correctly_grouped_prefixwc導致了分段錯誤,但它很可能是其他代碼段的錯誤參數,可能是strtodstrtol或稱爲它們的東西。這就是說,這裏是如何設置事件,以便gdb可以在__correctly_grouped_prefixwc中顯示導致分段錯誤的源代碼行。

要執行源代碼級調試,您需要一個可執行文件或共享對象的調試信息及其源代碼。通常Linux和Unix發行版默認不包含這些內容,以節省存儲空間,但是它們使它們可以作爲包使用。

在CentOS,你只需要安裝debuginfo軟包你感興趣的每個可執行文件或庫。要做到這一點,運行

sudo yum install yum-utils 

這將安裝debuginfo-install程序,然後運行

sudo debuginfo-install glibc 

要下載並安裝glibc-debuginfo-2.5-123程序包(您的版本號可能會有所不同)。這將安裝許多其他文件,/usr/lib/debug/lib64/libc.so.6.debug,/usr/lib/debug/lib64/libc-2.5.so.debug/usr/src/debug/glibc-2.5-20061008T1257/stdlib/grouping.c,這些都是您所需要的。

debuginfo-install是一個簡短的python程序,它啓用debuginfo存儲庫並下載並安裝與作爲參數提供的包相對應的debuginfo包,以及所有依賴項。作爲替代,您可以直接從http://debuginfo.centos.org(或任何鏡像)下載debuginfo軟件包,並使用rpm -i進行安裝。

您提到您收到錯誤沒有可用的debuginfo軟件包來安裝。也許你沒有配置debuginfo回購。在我的CentOS 5系統,配置文件/etc/yum.repos.d/CentOS-Debuginfo.repo

# All debug packages from all the various CentOS-5 releases 
# are merged into a single repo, split by BaseArch 
# 
# Note: packages in the debuginfo repo are currently not signed 
# 

[base-debuginfo] 
name=CentOS-5 - Debuginfo 
baseurl=http://debuginfo.centos.org/5/$basearch/ 
gpgcheck=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 
enabled=0 

對於其他版本中,添加了debuginfo軟回購一般說明在this CentOS wiki article