简体   繁体   English

我如何告诉 clang memory sanitizer 忽略某些库中的数据?

[英]How do I tell clang memory sanitizer to ignore data from certain libraries?

For example I'd like to ignore sqlite and zlib because I know they're well tested.例如,我想忽略 sqlite 和 zlib,因为我知道它们已经过良好测试。 I grabbed the zpipe.c example and built it like this.我抓取了zpipe.c示例并像这样构建它。 Keep in mind I'm using -lz and not building zlib myself.请记住,我使用的是-lz而不是自己构建 zlib。 I'm only building zpipe myself and want to limit the sanitize to that one file我只是自己构建 zpipe,并希望将清理限制在那个文件中

clang -g -fsanitize=undefined,memory zpipe.c -lz

I ran echo Test |./a.out and I got the following error我运行echo Test |./a.out并收到以下错误

Uninitialized bytes in __interceptor_fwrite at offset 0 inside [0x7ffd61230bc0, 13)
==50435==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55767941cd85 in def /tmp/zlib-1.2.12/examples/zpipe.c:70:17
    #1 0x55767941e709 in main /tmp/zlib-1.2.12/examples/zpipe.c:186:15
    #2 0x7f65e834e30f in __libc_start_call_main libc-start.c
    #3 0x7f65e834e3c0 in __libc_start_main@GLIBC_2.2.5 (/usr/lib/libc.so.6+0x2d3c0)
    #4 0x5576793981d4 in _start (/tmp/zlib-1.2.12/examples/a.out+0x211d4)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/zlib-1.2.12/examples/zpipe.c:70:17 in def

Is there a way I can say assume any data that goes in and out of zlib or sqlite to be safe to use?有没有一种方法可以让我假设进出 zlib 或 sqlite 的任何数据都可以安全使用? I'll be linking both and only want to sanitize my own code我将链接两者并且只想清理我自己的代码

You can use an ignore list file.您可以使用忽略列表文件。 https://clang.llvm.org/docs/SanitizerSpecialCaseList.html https://clang.llvm.org/docs/SanitizerSpecialCaseList.html

Usage:用法:

clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c 

See the documentation for details on the format of the file.有关文件格式的详细信息,请参阅文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我怎么应该在铿锵声中使用消毒杀菌剂? - How I'm supposed to use the sanitizer in clang? 如何在Xcode中启用Clang Address Sanitizer? - How do you enable Clang Address Sanitizer in Xcode? 如何告诉 CMake 在 Windows 上使用 Clang? - How do I tell CMake to use Clang on Windows? 铛内存清理程序(Linux)不报告错误 - clang memory sanitizer (linux) does not report errors 如何告诉Clang忽略“属性与[超类]属性类型不兼容”警告? - How can I tell Clang to ignore `property incompatible with [super class] property type` warning? 如何使用带有 ASAN_POISON_MEMORY_REGION 宏(在 clang++ 中)的地址消毒剂中毒 function? - How to use poisoning function of address sanitizer with ASAN_POISON_MEMORY_REGION macro (at clang++)? 如何在 OSX 上使用 clang 线程消毒剂? - How to use clang thread sanitizer on OSX? 如何使用系统提供的较新版本的clang链接到线程消毒剂? - How can I link to thread sanitizer with a newer version of clang than the system provides? 如何编译与 llvm-link 链接的文件并将我的自定义库和编译器传递给 clang? - How do I compile files linked with llvm-link and pass my customized libraries and compiler pass to clang? 如何有选择地忽略clang关于使用已弃用的objective-c实现的警告? - How do I selectively ignore clang's warnings about use of deprecated objective-c implementations?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM