Repository navigation
cmake: enable building with Sanitizers - #56241
Conversation
0d47a1b to
416bae3
Compare
|
We also need |
8b97964 to
b23c0f2
Compare
@huww98 thanks! IMHO, |
79fd0fd to
04b5d91
Compare
|
bummer, we cannot enable |
|
6e282f4 to
2cf79b8
Compare
|
v2:
|
81fe6cb to
5ec3efe
Compare
it seems when cythonizing rados python binding, the linker fails to pull in libasan. |
5ec3efe to
72dbd27
Compare
26041a6 to
f2dffdc
Compare
e132210 to
974c8d2
Compare
|
some of the leakages should be addressed by #56461 |
|
@cbodley hi Casey, thank you for your reviews of the fixes of the leaks identified by LeakSanitizer. i am wondering if it is acceptable to get part of the changeset merged before we address all of the leaks? for two reasons:
if you are for this proposal, i will extract the last commit which enables ASan by default into another PR, and try to get the rest of the changes into main. otherwise, i will continue the efforts to get a clean run. it might take a while though. what do you think? |
works for me |
974c8d2 to
241891a
Compare
|
v6:
|
otherwised we'd have
```
CMake Error at cmake/modules/FindSanitizers.cmake:17 (if):
if given arguments:
"address" "IN_LIST" "address" "thread" "undefined_behavior" "OR" "leak" "IN_LIST" "address" "thread" "undefined_behavior"
Unknown arguments specified
```
when enabling TSan with WITH_TSAN=ON.
Signed-off-by: Kefu Chai <[email protected]>
so we can be alerted if UBSan identify something wrong. Signed-off-by: Kefu Chai <[email protected]>
instead of overriding CMAKE_EXE_LINKER_FLAGS, let's append to it. so that the existing `CMAKE_EXE_LINKER_FLAGS` is not overriden. this should enable us to build with Clang and with sanitizer(s) enabled. Signed-off-by: Kefu Chai <[email protected]>
…on extensions if sanitizers are enabled, we have to populate the required link flags to python extensions's building workflow. otherwise ld would fail to link like: ``` /usr/bin/ld: /home/jenkins-build/build/workspace/ceph-pull-requests/build/lib/libceph-common.so.2: undefined reference to `__asan_stack_free_10' ``` Signed-off-by: Kefu Chai <[email protected]>
when building python bindings extensions using Cython, we first perform sanity checks by building an executable and linking it against the shared library of the C language binding. if the executable builds, we consider the sanity test passes. before this change, we don't add `LDFLAGS` specified in environmental variable to the ldflags when building the executable. but we need to link against libasan, so that the symbols used by, for instance, librados.so, can be found by the executable. in this change, we always check `LDFLAGS`, and add it to the ldflags when building the executable for testing, if it's set. Signed-off-by: Kefu Chai <[email protected]>
turns out we have multiple copies of following symbol defined by rbd executable: ``` AddressSanitizer: odr-violation: global 'ceph::buffer::list::always_empty_bptr' at /home/jenkins-build/build/workspace/ceph-pull-requests/src/common/buffer.cc:1267:34 ``` before addressing it. let's disable this warning. Refs https://tracker.ceph.com/issues/65098 Signed-off-by: Kefu Chai <[email protected]>
there are known leaks, which are tracked by qa/lsan.suppr, in Ceph. so let's reuse it so we don't see them when running unit test with ASan enabled. see also https://clang.llvm.org/docs/AddressSanitizer.html#issue-suppression Signed-off-by: Kefu Chai <[email protected]>
LeakSanitizer reports
```
==688591==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 45 byte(s) in 1 object(s) allocated from:
#0 0x55f8dd9969dd in operator new(unsigned long) (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/unittest_fastbmap_allocator+0x1f89dd) (BuildId: cac39eac8ef1e8774f9dd48e6e3f677fdd864776)
#1 0x55f8dd99c730 in __gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ext/new_allocator.h:127:27
#2 0x55f8dd99c690 in std::allocator<char>::allocate(unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/allocator.h:185:32
#3 0x55f8dd99c690 in std::allocator_traits<std::allocator<char> >::allocate(std::allocator<char>&, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/alloc_traits.h:464:20
#4 0x55f8dd99c393 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/basic_string.tcc:153:14
#5 0x55f8dda96a6c in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/basic_string.tcc:307:21
#6 0x55f8dda96852 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/basic_string.tcc:395:8
#7 0x7f4a751ab6f0 in
MallocExtension::Initialize() (/lib/x86_64-linux-gnu/libtcmalloc.so.4+0x2a6f0) (BuildId:
eeef3d1257388a806e122398dbce3157ee568ef4)
```
this is a global object allocated by the allocator, so we can suppress this report.
Signed-off-by: Kefu Chai <[email protected]>
241891a to
1a80165
Compare
|
v7:
|
|
|
jenkins test make check |
1 similar comment
|
jenkins test make check |
|
thank you Casey, i am continuing the saga at #56537 . |
|
Hi, I'm seeing this error now when building the latest main on a vossi: Is there any prerequisite I need to install? I've configured with |
|
Classic: found the answer after posting. Looks like my python is out of date. |
|
i can create a workaround, if we have to support python 3.6. |
|
@leonid-s-usov @tchaikov It seems the shaman CentOS8 builders, which serve as the base for container images, aren't current with the ":=" syntax. Could you take a look at #56544 ? |
when performing tests, we should enable sanitizers for detecting potential issues. so, in this change, we address various issues in CMake when enabling ASsan, TSan and UBSan.
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e