且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在AddressSanitizer错误上生成核心转储

更新时间:2022-06-17 23:53:38

您需要设置环境变量来请求核心转储

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.