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

/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调试向量实现。它不会为您提供有关堆栈跟踪的更多信息,而只是中止执行(例如_FORTIFY_SOURCE)。

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

10-11 21:55
查看更多