首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有地址消毒液的clang 32位

有地址消毒液的clang 32位
EN

Stack Overflow用户
提问于 2022-11-14 15:44:48
回答 1查看 48关注 0票数 0

我正在用nix构建一个可复制的构建环境。代码是在32位模式下用clang-10构建的。而且它和ASAN有联系。

clang a.c -m32 -fsanitize=leak

我正在使用pkgsi686Linux.clang_10包在shell.nix中

这就是我所犯的错误:

/nix/store/4c4fy3hs558qm0ykif24f200d8mvcrkb-binutils-2.35.1/bin/ld:找不到/nix/store/h4h6h98m32xcp18vcbd2mx5rfd34bmw1-clang-wrapper-10.0.1/resource-root/lib/linux/libclang_rt.lsan-i386.a:没有这样的文件或目录clang-10:错误:链接器命令失败,退出代码1(使用-v查看调用)

似乎找不到带有libclang_rt.lsan-i386.a.的nix包我怎么才能解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2022-11-23 03:42:28

你坚持使用clang 10吗?对于最近的clang,一切都如预期的那样工作;对于测试,只需禁用使用-O0的优化,否则就不会出现泄漏(使用12、13和14测试,运行二进制时使用clang 11测试,得到一些错误==517055==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22))。

为了演示,我创建了一个flake 这里

代码语言:javascript
复制
$ nix build 'git+https://gist.github.com/tobiasBora/0952c923d3cd892e41fbc3ef025ac020?ref=main#hello'

$ file ./result/bin/a.out
./result/bin/a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped

$ ./result/bin/a.out
Hello world

=================================================================
==548464==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7 byte(s) in 1 object(s) allocated from:
    #0 0x40c4f2  (/nix/store/3i0ipj0zwpjm8g1fslvfjb5dng4bd9s0--/bin/a.out+0x40c4f2)
    #1 0x43b858  (/nix/store/3i0ipj0zwpjm8g1fslvfjb5dng4bd9s0--/bin/a.out+0x43b858)
    #2 0x7f381db5624d  (/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib/libc.so.6+0x2924d) (BuildId: 2bb226bc600b443958c7566207d0d02f8345e6ea)

SUMMARY: LeakSanitizer: 7 byte(s) leaked in 1 allocation(s).

$ nix build 'git+https://gist.github.com/tobiasBora/0952c923d3cd892e41fbc3ef025ac020?ref=main#hello-32'

$ file ./result/bin/a.out
./result/bin/a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /nix/store/bzw74a7dla8iqk2h8wshwi03fbgj2c5h-glibc-2.35-163/lib/ld-linux.so.2, for GNU/Linux 2.6.32, not stripped

$ ./result/bin/a.out

Hello world

=================================================================
==554039==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7 byte(s) in 1 object(s) allocated from:
    #0 0x8055779  (/nix/store/yh4klla6n8c9flgcxd7r05zj705kycdl--/bin/a.out+0x8055779)
    #1 0x8094238  (/nix/store/yh4klla6n8c9flgcxd7r05zj705kycdl--/bin/a.out+0x8094238)
    #2 0xf7c102f9  (/nix/store/bzw74a7dla8iqk2h8wshwi03fbgj2c5h-glibc-2.35-163/lib/libc.so.6+0x212f9) (BuildId: 0fc69f6f66391d65b1e33788a951319bda8ba1d4)

SUMMARY: LeakSanitizer: 7 byte(s) leaked in 1 allocation(s).
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74434312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档