clang address sanitizer: stacktrace seems to be truncated

huangapple go评论64阅读模式
英文:

clang address sanitizer: stacktrace seems to be truncated

问题

我使用以下选项在调试模式下编译了我的C++程序:-fsanitize=address -fno-optimize-sibling-calls。在程序的最后,我得到了以下错误:

==3985624==错误:检测到内存泄漏

从程序中分配了3个对象的内存泄漏792字节,分配位置如下:

  1. operator new[](unsigned long) 中,位于 ../../../../src/libsanitizer/asan/asan_new_delete.cpp:98
  2. tbb::internal::task_stream<3>::initialize(unsigned int) 中,位于 /calculate/dealii-9.3.2/opt/spack/linux-ubuntu22.04-skylake/gcc-12.1.0/intel-tbb-2020.3-ulfjl2ollhdkou6aoriwp27nlydyzuvj/lib/libtbb_debug.so.2+0x415e2
  3. tbb::internal::arena::arena(tbb::internal::market&, unsigned int, unsigned int) 中,位于 ../../src/tbb/arena.cpp:270

另外,还有1个对象的内存泄漏544字节,分配位置如下:

  1. operator new[](unsigned long) 中,位于 ../../../../src/libsanitizer/asan/asan_new_delete.cpp:98
  2. (/calculate/dealii-9.3.2/opt/spack/linux-ubuntu22.04-skylake/gcc-12.1.0/oce-0.18.3-ecsmaa46gxbflztayfsqannu7m66vwcb/lib/libTKernel.so.11+0xa3fb3)

我如何能够获取从我的程序的主函数开始的完整堆栈跟踪?我在这里看到的信息对我来说并不是特别有帮助。

我也尝试了 -fno-omit-frame-pointer 选项,但这也没有给我提供完整的堆栈跟踪。ASAN_SYMBOLIZER_PATH 环境变量已设置。

英文:

I compiled my c++ program in debug mode with the options -fsanitize=address -fno-optimize-sibling-calls. At the very end of the program, I got the following error:

==3985624==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 792 byte(s) in 3 object(s) allocated from:
    #0 0x7fecc2078608 in operator new[](unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:98
    #1 0x7feca17525e2 in tbb::internal::task_stream&lt;3&gt;::initialize(unsigned int) (/calculate/dealii-9.3.2/opt/spack/linux-ubuntu22.04-skylake/gcc-12.1.0/intel-tbb-2020.3-ulfjl2ollhdkou6aoriwp27nlydyzuvj/lib/libtbb_debug.so.2+0x415e2)
    #2 0x7feca174daf0 in tbb::internal::arena::arena(tbb::internal::market&amp;, unsigned int, unsigned int) ../../src/tbb/arena.cpp:270
    #3 0x7feca174dc64 in tbb::internal::arena::allocate_arena(tbb::internal::market&amp;, unsigned int, unsigned int) ../../src/tbb/arena.cpp:293
    #4 0x7feca1749a68 in tbb::internal::market::create_arena(int, int, unsigned long) ../../src/tbb/market.cpp:314
    #5 0x7feca1747980 in tbb::internal::governor::init_scheduler(int, unsigned long, bool) ../../src/tbb/governor.cpp:197
    #6 0x7feca174845a in tbb::task_scheduler_init::initialize(int, unsigned long) ../../src/tbb/governor.cpp:490
    #7 0x7feca17483a8 in tbb::task_scheduler_init::initialize(int) ../../src/tbb/governor.cpp:478
    #8 0x7fecb5ea073f in dealii::MultithreadInfo::set_thread_limit(unsigned int) /calculate/temp/ltmadmin/spack-stage-dealii-9.3.2-fpaxcn6bqnnmqjyg5nnmil5csgbvxate/spack-src/source/base/multithread_info.cc:93
    #9 0x7fecb5ea0ada in dealii::MultithreadInfo::initialize_multithreading() /calculate/temp/ltmadmin/spack-stage-dealii-9.3.2-fpaxcn6bqnnmqjyg5nnmil5csgbvxate/spack-src/source/base/multithread_info.cc:132
    #10 0x7fecb5ea0af8 in DoOnce /calculate/temp/ltmadmin/spack-stage-dealii-9.3.2-fpaxcn6bqnnmqjyg5nnmil5csgbvxate/spack-src/source/base/multithread_info.cc:147
    #11 0x7fecb5ea4297 in __static_initialization_and_destruction_0 /calculate/temp/ltmadmin/spack-stage-dealii-9.3.2-fpaxcn6bqnnmqjyg5nnmil5csgbvxate/spack-src/source/base/multithread_info.cc:149
    #12 0x7fecb5ea42b1 in _GLOBAL__sub_I_multithread_info.cc /calculate/temp/ltmadmin/spack-stage-dealii-9.3.2-fpaxcn6bqnnmqjyg5nnmil5csgbvxate/spack-src/source/base/multithread_info.cc:152
    #13 0x7fecc269347d in call_init elf/dl-init.c:70

Direct leak of 544 byte(s) in 1 object(s) allocated from:
    #0 0x7fecc2078608 in operator new[](unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:98
    #1 0x7fec98529fb3  (/calculate/dealii-9.3.2/opt/spack/linux-ubuntu22.04-skylake/gcc-12.1.0/oce-0.18.3-ecsmaa46gxbflztayfsqannu7m66vwcb/lib/libTKernel.so.11+0xa3fb3)

How can I get the full stack trace starting from the main function of my program? What I see here is not really helpful to me.

I also tried the option -fno-omit-frame-pointer but this also gives me not the full stacktrace. The ASAN_SYMBOLIZER_PATH environment variable is set.

答案1

得分: 2

By default Asan/Lsan collect malloc stacktraces by following chain of frame pointers. If particular library is compiled without FP support (i.e. with -fomit-frame-pointer) the chain gets broken along the way which is exactly what you experience here.

You could instead use a more reliable (but also much slower) stacktrace collection via export ASAN_OPTIONS=fast_unwind_on_malloc=false

英文:

By default Asan/Lsan collect malloc stacktraces by following chain of frame pointers. If particular library is compiled without FP support (i.e. with -fomit-frame-pointer) the chain gets broken along the way which is exactly what you experience here.

You could instead use a more reliable (but also much slower) stacktrace collection via export ASAN_OPTIONS=fast_unwind_on_malloc=false

huangapple
  • 本文由 发表于 2023年3月31日 21:31:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75899124.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定