c++ - 在 cpp 中使用回溯调试段错误

标签 c++ linux segmentation-fault backtrace

在我的代码(用 cpp 编写)中,我遇到了以下回溯的段错误:

Got signal 11
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0xa053)[0x55614154e053]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0xa05e)[0x55614154e05e]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fad)[0x55614154dfad]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fc9)[0x55614154dfc9]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fb5)[0x55614154dfb5]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0xa022)[0x55614154e022]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fb5)[0x55614154dfb5]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fb1)[0x55614154dfb1]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9ca5)[0x55614154dca5]
./build/debug/lock_free_list_test(+0x9fc9)[0x55614154dfc9]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fb5)[0x55614154dfb5]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fc1)[0x55614154dfc1]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fb5)[0x55614154dfb5]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
Got signal 11
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0xa053)[0x55614154e053]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test==== start backtrace ====
(+0x9fb5)[0x55614154dfb5]
/lib/x86_64-linux-gnu/libpthread.so.0./build/debug/lock_free_list_test(+0x9fc9)[0x55614154dfc9]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
(./build/debug/lock_free_list_test+0x(13150+0x)49bf[0x)7ff25eb6f150[0x]
5561415489bf./build/debug/lock_free_list_test]
./build/debug/lock_free_list_test(+0x(9ca2+0x)4789[0x)55614154dca2[0x]
556141548789./build/debug/lock_free_list_test]
(./build/debug/lock_free_list_test+0x9fc9()+0x[0x7c5f55614154dfc9)]
[0x./build/debug/lock_free_list_test55614154bc5f]
(./build/debug/lock_free_list_test+0x9159()+0x[0xca5155614154d159)]
[0x./build/debug/lock_free_list_test556141550a51]
(./build/debug/lock_free_list_test+0x(49bf+0x)ffa8[0x)5561415489bf[0x]
556141553fa8./build/debug/lock_free_list_test]
(./build/debug/lock_free_list_test+0x4789()+0x[0x10ba7556141548789)]
[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0./build/debug/lock_free_list_test((+0x+0x77fc7c5f))[0x[0x7ff25eb637fc55614154bc5f]
]
==== end backtrace ====
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc)[0x7ff25eb637fc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ff25e2f3b0f]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10f96)[0x7ff25eb6cf96]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11054)[0x7ff25eb6d054]
/lib/x86_64-linux-gnu/libpthread.so.0(sem_wait+0x64)[0x7ff25eb6d144]
./build/debug/lock_free_list_test(+0x101d9)[0x5561415541d9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0xa053)[0x55614154e053]
./build/debug/lock_free_list_test(+0x9159)[0x55614154d159]
./build/debug/lock_free_list_test(+0x49bf)[0x5561415489bf]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x556141554ba7]
==== end backtrace ====
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7ff25eb6f150]
./build/debug/lock_free_list_test(+0x9fb5)[0x55614154dfb5]
./build/debug/lock_free_list_test(+0x90bf)[0x55614154d0bf]
./build/debug/lock_free_list_test(+0x498c)[0x55614154898c]
./build/debug/lock_free_list_test(+0x4789)[0x556141548789]
./build/debug/lock_free_list_test(+0x7c5f)[0x55614154bc5f]
./build/debug/lock_free_list_test(+0xca51)[0x556141550a51]
./build/debug/lock_free_list_test(+0xffa8)[0x556141553fa8]
./build/debug/lock_free_list_test(+0x10ba7)[0x==== start backtrace ====
556141554ba7]
==== start backtrace ====
/lib/x86_64-linux-gnu/libpthread.so.0/lib/x86_64-linux-gnu/libpthread.so.0/lib/x86_64-linux-gnu/libpthread.so.0((+0x+0x77fc13150))[0x[0x7ff25eb637fc(7ff25eb6f150]
+0x]
./build/debug/lock_free_list_test13150)[0x7ff25eb6f150(]
+0x./build/debug/lock_free_list_test9fb5)([0x+0x/lib/x86_64-linux-gnu/libc.so.69fb555614154dfb5]
)./build/debug/lock_free_list_test[0x55614154dfb5]
(+0x./build/debug/lock_free_list_test90bf)[0x55614154d0bf(]
+0x./build/debug/lock_free_list_test90bf)([0x+0x55614154d0bf498c]
)./build/debug/lock_free_list_test[0x(55614154898c(]
+0xclone./build/debug/lock_free_list_test498c+0x)3f[0x)(55614154898c[0x+0x]
7ff25e2f3b0f4789./build/debug/lock_free_list_test]
)(==== end backtrace ====
[0x+0x5561415487894789]
)./build/debug/lock_free_list_test[0x556141548789Segmentation fault (core dumped)

那么有没有办法调试这个并在哪一行发生段错误? (我在这里找不到任何这样的帖子,如果重复我会删除它)。 代码本身非常大,所以我想在这里输入它是不正确的,我只是想知道我是否可以使用回溯调试代码。

最佳答案

In my code (written in cpp) I am getting a segmentation fault with following backtrace:

这(显然)是您的测试框架的输出。

虽然它包含相当多的有用信息,但您将从调试器中获得很多更多有用信息(假设您已经编译测试以使用 -g标志)。

gdb build/debug/lock_free_list_test
(gdb) run
... wait for SIGSEGV
(gdb) where        ## should print file and line info leading to the crash
(gdb) info locals  ## should print values of local variables and parameters

如果出于某种原因您不能或不想使用调试器,您至少可以从现有的崩溃中获取函数、文件和行信息(再次假设您已经使用 - 构建了测试) g 标志):

addr2line -fe build/debug/lock_free_list_test 0xa053 0x9159 ...

关于c++ - 在 cpp 中使用回溯调试段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48048563/

相关文章:

c++ - 增加队列大小并找到最短队列

c++ - 介于 multimap 和 vector 之间的数据结构

c++ - Windows 更新代理纯 win32 API

c++ - 我找不到 valgrind 告诉我的内存链接

linux - DPDK解绑后如何领取网卡?

linux - 同台机器上的员工副本 : Error registering with STAF, RC:10

php - 加载 ffmpeg-php 模块失败

c++ - 分割故障QPainter

C:段错误 11 strcpy 指针数组

c - 为什么在写入使用字符串初始化的 "char *s"时会出现段错误,而不是 "char s[]"?