【问题标题】:Address Sanitizer option "-fsanitize-recover=address" is not supported不支持地址清理程序选项“-fsanitize-recover=address”
【发布时间】:2019-04-22 19:06:06
【问题描述】:

我正在尝试在我的项目中将 Address Sanitizer 与 gcc 一起使用。

所以,我在编译器和链接器中添加了所需的标志:

ADD_COMPILE_OPTIONS(-O0 -g -Wall -fsanitize=address -fno-omit-frame-pointer)
SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")

Address Sanitizer 在此之后工作,但它在第一个错误后中止我的应用程序。即使在报告错误后,我也希望 Address Sanitizer 继续运行。所以,我又添加了一个标志,如下所示(根据链接https://github.com/google/sanitizers/wiki/AddressSanitizer):

ADD_COMPILE_OPTIONS(-O0 -g -Wall -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer)

在此之后,我收到不支持此恢复标志的错误:

Problems were encountered while collecting compiler information:
cc1plus: error: -fsanitize-recover=address is not supported

PS : 我的 gcc 版本是 gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609

【问题讨论】:

    标签: gcc cmake address-sanitizer


    【解决方案1】:

    我相信 gcc 6 是最早支持 Asan 恢复模式的版本。此模式是在 Nov 2015 中添加的,而 GCC 5 是在 2015 年 4 月发布的。

    您可以install GCC 6 或使用 Clang。

    【讨论】:

    • 感谢您的回复。我已经安装了 Clang 来使用这个功能。因此,要使用此恢复功能,您基本上需要 GCC 6+ 或 Clang 2.8+ 实际上较新的 Clang 版本有一个更好的选择来添加一个包含您不需要清理的所有功能的 txt 文件 (-fsanitize-blacklist)
    • @mascot 我想你的意思是 Clang 3.8。
    • 完全准确地说,根据您之前提到的the commit info,支持从 GCC 6.1.0 开始提供。
    • @szotsaki 是的,但是有 no GCC 6.0 release 所以我把它叫做 GCC 6。
    猜你喜欢
    • 1970-01-01
    • 2017-06-24
    • 1970-01-01
    • 2013-04-14
    • 2016-11-01
    • 2018-06-23
    • 2017-09-09
    • 2018-04-04
    相关资源
    最近更新 更多