Skip to content

cmake: some fixes and suppressions for WITH_ASAN under vstart.sh - #50385

Merged
cbodley merged 3 commits into
ceph:mainfrom
cbodley:wip-cmake-asan
Mar 12, 2023
Merged

cbodley merged 3 commits into
ceph:mainfrom
cbodley:wip-cmake-asan

Conversation

@cbodley

@cbodley cbodley commented Mar 5, 2023

Copy link
Copy Markdown
Contributor
  • boost::context understands a BOOST_USE_ASAN define to add asan annotations to its context switches. BuildBoost.cmake adds this define when our cmake variable WITH_ASAN is set

  • src/ceph.in automatically adds libasan.so to LD_PRELOAD, but its detection logic in FindSanitizers.cmake wasn't looking for newer versions of the library. on fedora 37, i have libasan.so.8 installed

  • memory leaks in bin/ceph-mon and the bin/ceph prevented vstart.sh from bootstrapping the cluster, so a qa/lsan.supp file was added to suppress them. the suppressions are enabled with the environment variable LSAN_OPTIONS="suppressions=../qa/lsan.supp"

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@cbodley

cbodley commented Mar 5, 2023

Copy link
Copy Markdown
Contributor Author

tested only with gcc using WITH_ASAN=ON WITH_UBSAN=ON

Comment thread qa/lsan.supp Resolved
@yuvalif

yuvalif commented Mar 5, 2023

Copy link
Copy Markdown
Contributor

had to add the following option:

ASAN_OPTIONS="detect_odr_violation=0"

to avoid:

==2841973==ERROR: AddressSanitizer: odr-violation (0x5624b9734a40):
  [1] size=16 'alloc_pgmap_inc' ../src/mon/PGMap.cc:42:1
  [2] size=16 'alloc_pgmap_inc' ../src/mon/PGMap.cc:42:1

@yuvalif yuvalif mentioned this pull request Mar 5, 2023
4 of 14 tasks
@cbodley

cbodley commented Mar 5, 2023 •

Copy link
Copy Markdown
Contributor Author

with the boost::context commit, i was hoping to get rid of these rgw::notify::Manager errors: https://gist.github.com/cbodley/a5d7b8f74f353bae6156c32076a8f281

but with boost::context compiled with asan and ucontext, i get a different one: https://gist.github.com/cbodley/d0ab0a9a75fcfeb5341e3a09f80eee5a

edit: also tried with ASAN_OPTIONS="detect_stack_use_after_return=true" and it got further, but crashed instead: https://gist.github.com/cbodley/9a98541c82664efd13ca3cfc19556d5b

@yuvalif

yuvalif commented Mar 5, 2023

Copy link
Copy Markdown
Contributor

with the boost::context commit, i was hoping to get rid of these rgw::notify::Manager errors: https://gist.github.com/cbodley/a5d7b8f74f353bae6156c32076a8f281

but with boost::context compiled with asan and ucontext, i get a different one: https://gist.github.com/cbodley/d0ab0a9a75fcfeb5341e3a09f80eee5a

i see the rgw::notify::Manager errors only in radosgw-admin.
maybe some shutdown issue?

@cbodley
cbodley requested a review from idryomov March 5, 2023 20:07
Comment thread qa/lsan.supp Resolved
Comment thread qa/lsan.supp Resolved
@yuvalif

yuvalif commented Mar 6, 2023

Copy link
Copy Markdown
Contributor

with the boost::context commit, i was hoping to get rid of these rgw::notify::Manager errors: https://gist.github.com/cbodley/a5d7b8f74f353bae6156c32076a8f281

but with boost::context compiled with asan and ucontext, i get a different one: https://gist.github.com/cbodley/d0ab0a9a75fcfeb5341e3a09f80eee5a

edit: also tried with ASAN_OPTIONS="detect_stack_use_after_return=true" and it got further, but crashed instead: https://gist.github.com/cbodley/9a98541c82664efd13ca3cfc19556d5b

this PR: #50403 should fix these errors

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of NAMES list in cmake/modules/FindSanitizers.cmake but we already touched on that in #50320 (comment). Otherwise LGTM!

@cbodley

cbodley commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

Not a fan of NAMES list in cmake/modules/FindSanitizers.cmake

i could imagine vstart.sh and vstart_environment.sh exporting the necessary LD_PRELOAD/ASAN_OPTIONS/LSAN_OPTIONS

that could avoid the ASAN_LIBRARY logic for src/ceph.in, but would only cover vstart clusters - other deployments would have to add these options manually

using ldd to discover the libasan so version (if it's enabled at all) would be easier to do in vstart, where we know the location of our ceph binaries. in the ceph python command, it's less clear what we'd run ldd on

personally, i'm most interested in enabling asan for a) local vstart testing, and b) jenkins 'make check'. what do you guys think?

@yuvalif

yuvalif commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

I'm trying on fedora 37. with libasan-12.2.1-4.fc37.x86_64 (and /usr/lib64/libasan.so.8)
after running:

cmake -DWITH_ASAN=ON -DWITH_UBSAN=ON ..

i get a cmake error:

-- Performing Test Sanitizers_ARE_SUPPORTED
-- Performing Test Sanitizers_ARE_SUPPORTED - Failed
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Sanitizers (missing: Sanitizers_ARE_SUPPORTED)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindSanitizers.cmake:63 (find_package_handle_standard_args)
  CMakeLists.txt:603 (find_package)

Comment thread qa/lsan.supp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this time the correct functions that should be added when running with rhel8 (Python 3.6.8):

leak:^_PyObject_Alloc
leak:^PyType_GenericAlloc
leak:^PyBytes_FromStringAndSize
leak:^set_table_resize

@cbodley

cbodley commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

-- Performing Test Sanitizers_ARE_SUPPORTED
-- Performing Test Sanitizers_ARE_SUPPORTED - Failed

this would be coming from check_cxx_source_compiles("int main() {}" Sanitizers_ARE_SUPPORTED)

you should be able to find the compilation error message from that in build/CMakeFiles/CMakeError.log

@idryomov

idryomov commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

in the ceph python command, it's less clear what we'd run ldd on

I suggested running it on rados command in the same directory. rados should always be present if ceph is, right?

@cbodley

cbodley commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

I suggested running it on rados command in the same directory. rados should always be present if ceph is, right?

oops, i had assumed that rados was also a python script 👍 so the vstart piece would only need to add any ASAN_OPTIONS/LSAN_OPTIONS

@yuvalif

yuvalif commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

can we also add -fsanitize-recover=address to the compilation options?
according to this: https://github.com/google/sanitizers/wiki/AddressSanitizerFlags it is needed if we want to set halt_on_error=0 (which is currently needed for the RGW).

@yuvalif

yuvalif commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

build/CMakeFiles/CMakeError.log

no error file

@yuvalif

yuvalif commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

ASAN found another issue. fixed here: #50425

@cbodley

cbodley commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

ASAN found another issue. fixed here: #50425

that's a dup of #50383, sorry. i had linked that in a comment above

@yuvalif

yuvalif commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

with the boost::context commit, i was hoping to get rid of these rgw::notify::Manager errors: https://gist.github.com/cbodley/a5d7b8f74f353bae6156c32076a8f281
but with boost::context compiled with asan and ucontext, i get a different one: https://gist.github.com/cbodley/d0ab0a9a75fcfeb5341e3a09f80eee5a
edit: also tried with ASAN_OPTIONS="detect_stack_use_after_return=true" and it got further, but crashed instead: https://gist.github.com/cbodley/9a98541c82664efd13ca3cfc19556d5b

this PR: #50403 should fix these errors

only fixed radosgw-admin issue. not the RGW issue :-(

cbodley added 2 commits March 7, 2023 13:33
any executable that links against the heap_profiler leaks 8 bytes for a
singleton:
> -----------------------------------------------------
> Suppressions used:
> count      bytes template
> 1          8 ^MallocExtension::Register
> -----------------------------------------------------

the python script bin/ceph has a lot of leaks:
> -----------------------------------------------------
> Suppressions used:
>   count      bytes template
>     205     294983 ^PyObject_Malloc
>      10       6216 ^_PyObject_Realloc
>       1        568 ^PyMem_Calloc
>       2          2 ^PyMem_Malloc
>      63      58935 ^PyUnicode_New
>      10       7294 ^_PyBytes_FromSize
>     166     149904 ^_PyObject_GC_Alloc
>       5       3360 ^_PyObject_GC_Resize
> -----------------------------------------------------

Signed-off-by: Casey Bodley <[email protected]>
@cbodley

cbodley commented Mar 11, 2023

Copy link
Copy Markdown
Contributor Author

@cbodley
cbodley merged commit 48d53b4 into ceph:main Mar 12, 2023
@cbodley
cbodley deleted the wip-cmake-asan branch March 12, 2023 18:30
@cbodley cbodley mentioned this pull request Mar 16, 2023
3 of 14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants