ASAN-抑制外部库中的报告(LLVM 13,Windows)



我试图在外部库中抑制ASAN问题,因此我遵循llvm ASAN抑制外部库中的报告,文档说:

如果您在外部库中遇到问题,我们建议您立即向库维护人员报告,以便得到解决区块报价

更新:这里是问题的链接,问题45842:AddressSanitizer:免费-你好世界c扩展-Python跟踪器

ASAN跟踪

==6968==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x01e7aceb3be0 in thread T0
#0 0x7ffec9a97f31  (D:amin_reprex_python_c_extension_asanmin_reprex_python_c_extension_asanllvmlibclang13.0.0libwindowsclang_rt.asan_dynamic-x86_64.dll+0x180037f31)
#1 0x7ffeca696030  (C:hostedtoolcachewindowsPython3.10.0x64python310.dll+0x180026030)
#2 0x7ffeca67aaaf  (C:hostedtoolcachewindowsPython3.10.0x64python310.dll+0x18000aaaf)
...
#114 0x7ff72208122f  (C:hostedtoolcachewindowsPython3.10.0x64python.exe+0x14000122f)
#115 0x7ffefee17973  (C:WindowsSystem32KERNEL32.DLL+0x180017973)
#116 0x7fff0071a2f0  (C:WindowsSYSTEM32ntdll.dll+0x18005a2f0)
Address 0x01e7aceb3be0 is a wild pointer inside of access range of size 0x000000000001.
SUMMARY: AddressSanitizer: bad-free (D:amin_reprex_python_c_extension_asanmin_reprex_python_c_extension_asanllvmlibclang13.0.0libwindowsclang_rt.asan_dynamic-x86_64.dll+0x180037f31) 
==6968==ABORTING

这里有一个完整的ASAN跟踪链接。

到目前为止我做了什么

我创建了一个my_asan.supp,并按照文档中的建议加载了ASAN_OPTIONS=suppressions=my_asan.supp,其中包含以下内容:

interceptor_via_fun:_PyObject_Realloc
interceptor_via_fun:realloc
interceptor_via_lib:C:/Python39/python3.dll
interceptor_via_lib:C:/s/eklang/DevOps/clang/bin/LLVM-13.0.0-win64/lib/clang/13.0.0/lib/windows/clang_rt.asan_dynamic-x86_64.dll
interceptor_via_lib:C:/Windows/System32/KERNEL32.DLL
interceptor_via_lib:C:/Windows/SYSTEM32/ntdll.dll
interceptor_via_lib:C:Python39python3.dll
interceptor_via_lib:C:seklangDevOpsclangbinLLVM-13.0.0-win64libclang13.0.0libwindowsclang_rt.asan_dynamic-x86_64.dll
interceptor_via_lib:C:WindowsSystem32KERNEL32.DLL
interceptor_via_lib:C:WindowsSYSTEM32ntdll.dll
interceptor_via_lib:clang_rt.asan_dynamic-x86_64.dll
interceptor_via_lib:ntdll
interceptor_via_lib:ntdll.dll
interceptor_via_lib:python3
interceptor_via_lib:python3.dll
interceptor_via_lib:KERNEL32
interceptor_via_lib:KERNEL32.dll

这些似乎都不起作用,我做错了什么?我尝试了完整路径、正斜杠、反斜杠、dll名称。。。

信息

LLVM 13、Windows 10

当未使用asan编译的可执行文件(在本例中为python.exe(加载使用i编译的dll时。

需要确保首先加载asan运行时,它才能发挥神奇的作用,并正确拦截mallocfree,在linux下,很容易使用LD_PRELOAD(互联网上有很多关于如何做到这一点的例子(。

然而,在windows中,这似乎是不可能的,因此,一个解决方案似乎是制作一个链接了clang_rt.asan-preinit-x86_64.libclang_rt.asan-x86_64.lib的可执行包装,并从那里调用python,稍后将加载需要使用clang_rt.asan_dll_thunk-x86_64.lib编译的dll。

整个事情听起来相当复杂,但到目前为止似乎行之有效。这篇文章👀帮助了我。

最新更新