分段错误诊断

分段错误诊断

我正在尝试诊断升级到 Ubuntu 14.04(32 位)后开始出现的分段错误问题。我正在运行 TSM 客户端 6.2.5-4,在升级之前运行良好。我尝试使用 strace 来找到问题的核心,但我不明白问题是什么。

SIGSEGV 发生在 mmap2 调用之后,所以我认为这可能是由于内存交换空间不足造成的,但内存交换空间和内存交换空间都足够。在 mmap 调用之前,select 调用也超时了,所以可能与此有关。

老实说,我有点不知所措。我尝试询问 Ubuntu 社区和 TSM 社区,但都没有消息。所以我希望这里有人能告诉我如何阅读这个 strace,我将其结尾附加(其余部分可以在这里找到http://pastebin.com/dz1faACE)。我也很乐意提供任何其他可能有用的信息!提前谢谢!

open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
futex(0xb718be2c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
brk(0x9fa8000)                          = 0x9fa8000
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
brk(0x9fd9000)                          = 0x9fd9000
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
open("/proc/mounts", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "rootfs / rootfs rw 0 0\nsysfs /sy"..., 1024) = 1024
read(4, "lv001 /data ext4 rw,relatime,dat"..., 1024) = 46
read(4, "", 1024)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
brk(0x9fc0000)                          = 0x9fc0000
brk(0x9fa8000)                          = 0x9fa8000
brk(0x9f8f000)                          = 0x9f8f000
openat(AT_FDCWD, "/tmp/TSM", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
mmap2(NULL, 512000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb638b000
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
open("/proc/mounts", O_RDONLY|O_LARGEFILE) = 4
fstat64(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "rootfs / rootfs rw 0 0\nsysfs /sy"..., 1024) = 1024
read(4, "lv001 /data ext4 rw,relatime,dat"..., 1024) = 46
read(4, "", 1024)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
statfs64("/", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=3063340, f_bfree=708785, f_bavail=547416, f_files=786432, f_ffree=540306, f_fsid={-371423568, -29257012}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
statfs64("/proc", 84, {f_type="PROC_SUPER_MAGIC", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4142}) = 0
stat64("/proc", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
statfs64("/sys", 84, {f_type="SYSFS_MAGIC", f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4142}) = 0
stat64("/sys", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
statfs64("/sys/fs/cgroup", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=1, f_bfree=1, f_bavail=1, f_files=202220, f_ffree=202218, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/sys/fs/cgroup", {st_mode=S_IFDIR|0755, st_size=60, ...}) = 0
statfs64("/sys/fs/fuse/connections", 84, {f_type=0x65735543, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/sys/fs/fuse/connections", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
statfs64("/sys/kernel/debug", 84, {f_type=0x64626720, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/sys/kernel/debug", {st_mode=S_IFDIR|0700, st_size=0, ...}) = 0
statfs64("/sys/kernel/security", 84, {f_type=0x73636673, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/sys/kernel/security", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
statfs64("/dev", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=1033006, f_bfree=1033003, f_bavail=1033003, f_files=197227, f_ffree=196785, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/dev", {st_mode=S_IFDIR|0755, st_size=4240, ...}) = 0
open("/etc/fstab", O_RDONLY|O_CLOEXEC)  = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=989, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "# /etc/fstab: static file system"..., 4096) = 989
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
statfs64("/run", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=207101, f_bfree=206972, f_bavail=206972, f_files=202220, f_ffree=201823, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4138}) = 0
stat64("/run", {st_mode=S_IFDIR|0755, st_size=660, ...}) = 0
statfs64("/run/lock", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=1280, f_bfree=1280, f_bavail=1280, f_files=202220, f_ffree=202214, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4142}) = 0
stat64("/run/lock", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=120, ...}) = 0
statfs64("/run/shm", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=1035503, f_bfree=1035503, f_bavail=1035503, f_files=202220, f_ffree=202219, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4134}) = 0
stat64("/run/shm", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=40, ...}) = 0
statfs64("/run/user", 84, {f_type=0x1021994, f_bsize=4096, f_blocks=25600, f_bfree=25600, f_bavail=25600, f_files=202220, f_ffree=202217, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4142}) = 0
stat64("/run/user", {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0
statfs64("/sys/fs/pstore", 84, {f_type=0x6165676c, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/sys/fs/pstore", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
statfs64("/sys/fs/cgroup/systemd", 84, {f_type=0x27e0eb, f_bsize=4096, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={0, 0}, f_namelen=255, f_frsize=4096, f_flags=4142}) = 0
stat64("/sys/fs/cgroup/systemd", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
statfs64("/data", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=128981614, f_bfree=93342103, f_bavail=86784459, f_files=32768000, f_ffree=32451931, f_fsid={-1906668704, -244025993}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/data", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
munmap(0xb638b000, 512000)              = 0
statfs64("/", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=3063340, f_bfree=708785, f_bavail=547416, f_files=786432, f_ffree=540306, f_fsid={-371423568, -29257012}, f_namelen=255, f_frsize=4096, f_flags=4128}) = 0
stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/mtab", O_RDONLY|O_CLOEXEC)   = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=780, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "/dev/sda1 / ext4 rw,errors=remou"..., 4096) = 780
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
mmap2(NULL, 8392704, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xb5c07000
mprotect(0xb5c07000, 4096, PROT_NONE)   = 0
clone(child_stack=0xb6407424, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xb6407ba8, {entry_number:6, base_addr:0xb6407b40, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0xb6407ba8) = 13914
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
sched_yield()                           = 0
mmap2(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb5a06000
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x2} ---
time(NULL)                              = 1425498940
open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=2309, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0644, st_size=2309, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6a50000
read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\10\0\0\0\0"..., 4096) = 2309
_llseek(4, -28, [2281], SEEK_CUR)       = 0
read(4, "\nCET-1CEST,M3.5.0,M10.5.0/3\n", 4096) = 28
close(4)                                = 0
munmap(0xb6a50000, 4096)                = 0
write(3, "03/04/2015 20:55:40 ANS0361I DIA"..., 71) = 71
rt_sigaction(SIGABRT, {SIG_DFL, [], SA_RESTORER|SA_STACK|SA_RESTART|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|SA_SIGINFO|SA_NOCLDSTOP|SA_NOCLDWAIT|0x3fffff8, 0xb770c100}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(13911, 13911, SIGABRT)           = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=13911, si_uid=0} ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)

答案1

一种可能是,在mmap2调用之后,应用程序访问了之前通过调用取消映射的地址munmap。这也会抛出一个SIGSEGV。但你需要的不仅仅是strace看到这一点,一些内存调试器可以在运行时帮助你,比如valgrind

man 2 munmap

int munmap(void *addr, size_t length); 

[...]

地址 addr 必须是页面大小的倍数。所有包含指定范围一部分的页面均未映射,并且随后对这些页面的引用将生成 SIGSEGV。如果指定范围不包含任何映射页面,则不属于错误。

相关内容