libc.so.1 中的核心

问题描述 投票:0回答:3

我使用的是 Solaris 10,我的 C 程序崩溃并创建了一个核心文件。在调试时,似乎核心是在 libc.so.1 中创建的。如果有人有任何线索,请告诉我。 以下是 dbx 报告。

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.
t@null (l@1) 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
c unix solaris coredump libc
3个回答
2
投票

不,问题不在于 C 标准库。您正在向

strcasecmp()
传递无效参数(NULL 字符串指针等)。如果没有实际的代码(您尚未发布),就不可能推断出错误到底是什么。

(此外,你最好使用调试符号编译程序 - 关闭优化!如果你使用 Solaris,你很可能使用 GCC:

gcc -O0 -g etc...


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 现在会告诉您哪个函数正在调用

strcasecmp
。单步执行源代码(或让它生成日志输出),检查致命函数调用的参数是否存在任何异常情况(例如无效指针)。

与调用该函数出错的可能性相比,在 libc 函数中发现错误的可能性微乎其微。


0
投票

1) 运行 bt (backtrace) 以查看谁在调用 strcasecmp [这将列出像 #0、#1 这样的帧]

2) 现在跳转到特定帧以获取值 [frame 0]

3)然后显示/打印传递给strcasecmp的参数值(使用print或display)

我觉得调用 strcasecmp 时参数为 NULL,这就是您遇到段错误的原因。

© www.soinside.com 2019 - 2024. All rights reserved.