gpt4 book ai didi

c++ - 如何强制 ASan 显示不止一个调用堆栈行?

转载 作者:太空宇宙 更新时间:2023-11-04 13:13:51 24 4
gpt4 key购买 nike

目前,当我运行我的应用程序时,我得到下一个输出:

/usr/include/c++/4.8/debug/vector:346:error: attempt to subscript container
with out-of-bounds index 1, but container only holds 1 elements.

Objects involved in the operation:
sequence "this" @ 0x0x60400000fd30 {
type = NSt7__debug6vectorIdSaIdEEE;
}
Aborted (core dumped)

它是用官方 ubuntu 14.04 gcc 和编译标志编译的:

-fPIC -std=c++11 -fopenmp -Wall -pedantic -Wunused -O0 -g3 -fsanitize=address -fno-omit-frame-pointer -D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -fprofile-arcs - ftest-coverage --coverage

LLVM 和 clang 也是开箱即用的,应用程序是这样启动的:

ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4 ./app

为什么只出现一行调用堆栈?如何获取与我的应用程序相关的上下文?


注意:如果我从 GDB 下运行

gdb ./app
run
where

我获得可读的调用堆栈(包含行号和调用详细信息)。(gdb) 在哪里

#0  0x00007ffff3640c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff3644028 in __GI_abort () at abort.c:89
#2 0x00007ffff43c7fe5 in __gnu_debug::_Error_formatter::_M_error() const ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x0000000000427184 in std::__debug::vector<double, std::allocator<double> >::operator[] (this=0x60400000fd30,
__n=1) at /usr/include/c++/4.8/debug/vector:346
#4 0x00007ffff47f6bfa in GeneralParameters::GeneralParameters...

但我想在不为我的 100 多个单元测试应用程序中的每一个运行 gdb 的情况下获得调用堆栈输出 - 我想直接在 ctest -VV 上看到此类错误,它按顺序运行我的所有测试。

最佳答案

这个错误似乎不是来自 ASan,而是来自 STL 调试 vector 实现。它不会为您提供有关堆栈跟踪的太多信息,而只是中止执行(与例如 _FORTIFY_SOURCE 相同)。

关于c++ - 如何强制 ASan 显示不止一个调用堆栈行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38427371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com