如何停止使用 AddressSanitizer?
How to stop using AddressSanitizer?
我要在这里受到打击,因为我正在使用我不完全理解并且没有花时间这样做的工具。此时我只想从我的工作中快速删除不必要的步骤/依赖项。
在开发过程中,我使用 AddressSanitizer 查找 C 代码中出现段错误和其他问题的原因。我通过在 Makefile 中将 -fsanitize=address
添加到我的 CFLAGS
列表中来做到这一点。
现在,在解决了所有这些问题后,如果我从编译中删除此标志,我将无法再编译我的代码,并且会出现许多与此问题中描述的错误非常相似的错误...
~/xxx/util.c:20: undefined reference to __asan_option_detect_stack_use_after_return' /usr/bin/ld: ~/xxx/util.c:20: undefined reference to
__asan_stack_malloc_2'
usr/bin/ld: /xxx/util.c:23: undefined reference to __asan_report_store8' /usr/bin/ld: /xxx/util.c:40: undefined reference to
__asan_report_load8' /usr/bin/ld:
/xxx/util.c:45: undefined reference
to `__asan_report_load8' /usr/bin/ld:
And so on.
区别在于我只想正常编译我的代码。在那个问题中,他们建议将标志 -lasan
添加到 link/compile 步骤。这似乎不会帮助我停止使用 -fsanitize
,尽管我可能是错的。显然这里的链接步骤有问题。感觉好像我包含了一个我忘记在某处的依赖项,但我不记得这样做了。
我错过了什么?可能是显而易见的事情。另外,如果我需要提供有关我的编译步骤的更多信息,请告诉我。
I just want to compile my code normally
删除 -fsanitize=...
标志 应该 完全做到这一点。
您的问题很可能源于没有重建所有对象(当您更新 Makefile
时,make
不会自动知道重建所有内容)。
运行 make clean; make
或 find . -name '*.o' | xargs rm; make
应该可以解决问题。
问题很简单:要使其工作,-fsanitize=address
必须出现在 编译 和 链接命令行中.要禁用它,它不能在任何一个中使用。
您的构建目录中必须有旧的 .o
目标文件。一种解决方案是使用 make clean
删除中间文件或目标文件。
如果您没有 clean
目标,现在是编写它的好时机...或者如果有幸使用 ZSH,则使用 find -name '*.o' -delete
或 rm **/*.o
之类的东西.
我要在这里受到打击,因为我正在使用我不完全理解并且没有花时间这样做的工具。此时我只想从我的工作中快速删除不必要的步骤/依赖项。
在开发过程中,我使用 AddressSanitizer 查找 C 代码中出现段错误和其他问题的原因。我通过在 Makefile 中将 -fsanitize=address
添加到我的 CFLAGS
列表中来做到这一点。
现在,在解决了所有这些问题后,如果我从编译中删除此标志,我将无法再编译我的代码,并且会出现许多与此问题中描述的错误非常相似的错误...
~/xxx/util.c:20: undefined reference to
__asan_option_detect_stack_use_after_return' /usr/bin/ld: ~/xxx/util.c:20: undefined reference to
__asan_stack_malloc_2' usr/bin/ld: /xxx/util.c:23: undefined reference to__asan_report_store8' /usr/bin/ld: /xxx/util.c:40: undefined reference to
__asan_report_load8' /usr/bin/ld: /xxx/util.c:45: undefined reference to `__asan_report_load8' /usr/bin/ld: And so on.
区别在于我只想正常编译我的代码。在那个问题中,他们建议将标志 -lasan
添加到 link/compile 步骤。这似乎不会帮助我停止使用 -fsanitize
,尽管我可能是错的。显然这里的链接步骤有问题。感觉好像我包含了一个我忘记在某处的依赖项,但我不记得这样做了。
我错过了什么?可能是显而易见的事情。另外,如果我需要提供有关我的编译步骤的更多信息,请告诉我。
I just want to compile my code normally
删除 -fsanitize=...
标志 应该 完全做到这一点。
您的问题很可能源于没有重建所有对象(当您更新 Makefile
时,make
不会自动知道重建所有内容)。
运行 make clean; make
或 find . -name '*.o' | xargs rm; make
应该可以解决问题。
问题很简单:要使其工作,-fsanitize=address
必须出现在 编译 和 链接命令行中.要禁用它,它不能在任何一个中使用。
您的构建目录中必须有旧的 .o
目标文件。一种解决方案是使用 make clean
删除中间文件或目标文件。
如果您没有 clean
目标,现在是编写它的好时机...或者如果有幸使用 ZSH,则使用 find -name '*.o' -delete
或 rm **/*.o
之类的东西.