如何在AddressSanitizer错误上生成核心转储 [英] How to generate core dump on AddressSanitizer error
本文介绍了如何在AddressSanitizer错误上生成核心转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我这样编译我的代码以启用Asan:
I compiled my code like this to enable Asan:
g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer
但它永远不会产生核心转储,因此我以后可以检查错误。如何生成它?
but it never generates a core dump so that I can later examine the details of the error. How can I generate it?
推荐答案
您需要设置环境变量来请求核心转储
You need to set environment variable to request coredumps
export ASAN_OPTIONS=abort_on_error=1
此应该确实是默认值,但是由于历史原因,ASan只会以非零错误代码退出。
This should really be default but due to historic reasons ASan just exits with non-zero error code instead.
在64位系统上,您可能需要添加
On 64-bit systems you might need to add
export ASAN_OPTIONS=...:disable_coredump=0:unmap_shadow_on_exit=1
(核心转储默认情况下处于禁用状态,因为担心它们会太大)。
(coredumps are disabled by default there, in fear that they will be too large).
有关标志的完整列表您可以看到 Asan Wiki 。
For complete list of flags you can see Asan wiki.
这篇关于如何在AddressSanitizer错误上生成核心转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文