首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASAN AddressSanitizer抱怨内存泄漏

ASAN AddressSanitizer抱怨内存泄漏
EN

Stack Overflow用户
提问于 2020-10-23 09:20:53
回答 1查看 2.7K关注 0票数 0

我正在使用ASAN地址消毒剂来检测内存问题。当程序停止时,ASAN抱怨如下:

代码语言:javascript
复制
==102121==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 537 byte(s) in 1 object(s) allocated from:
    #0 0x75cb48 in operator new(unsigned long) (/home/app+0x75cb48)
    #1 0x7dca83 in __gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*) /opt/rh/devtoolset-7/root/usr/include/c++/7/ext/new_allocator.h:111
    #2 0x7ce766 in std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.tcc:1057
    #3 0x7cc54d in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (/home/app+0x7cc54d)
    #4 0x7c1f2a in std::string::reserve(unsigned long) /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.tcc:960
    #5 0x7fa0a639c6f5 in std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::overflow(int) (/lib64/libstdc++.so.6+0x9b6f5)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x75cec8 in operator new(unsigned long, std::nothrow_t const&) (/home/app+0x75cec8)
    #1 0x7fa0a635df1d in __cxa_thread_atexit (/lib64/libstdc++.so.6+0x5cf1d)

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x75cec8 in operator new(unsigned long, std::nothrow_t const&) (/home/app+0x75cec8)
    #1 0x7fa0a635df1d in __cxa_thread_atexit (/lib64/libstdc++.so.6+0x5cf1d)

我在ASAN页面上看到,它可以来自于标准库是静态链接的事实。虽然,在我的例子中,它是动态的。

该应用程序是在RHEL上用devtoolset-7编译的。

你知道泄漏是从哪里来的吗?

EN

回答 1

Stack Overflow用户

发布于 2020-10-23 09:45:50

你可以得到比

运算符

# 0x75cb48 (无符号长) (/home/app+0x75cb48)

通过使用llvm象征符。

下载它,并设置环境变量

代码语言:javascript
复制
ASAN_SYMBOLIZER_PATH=/usr/where/ever/the/binary/is

如果您确信泄漏是错误警报,则可以使用抑制文件:

创建抑制文本文件并添加到其中的leak: __cxa_thread_atexit

  • 集环境变量

LSAN_OPTIONS=suppressions=path/to/suppr.txt

然后运行你的应用程序。

http://clang.llvm.org/docs/AddressSanitizer.html#symbolizing-the-reports

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64497326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档