Skip to content

cmake: add a memcheck option for ctest - #56157

Closed
NitzanMordhai wants to merge 2 commits into
ceph:mainfrom
NitzanMordhai:wip-nitzan-unittest-with-valgrind
Closed

NitzanMordhai wants to merge 2 commits into
ceph:mainfrom
NitzanMordhai:wip-nitzan-unittest-with-valgrind

Conversation

@NitzanMordhai

@NitzanMordhai NitzanMordhai commented Mar 13, 2024 •

Copy link
Copy Markdown
Contributor

Adding the option to run the ctest with valgring so we will be able to find un-initialized variables.
To run the unit-test with memory check:
ctest -R name_test -T memcheck -j 80

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
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
  • jenkins test rook e2e

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch from ff88d60 to b2a5ee0 Compare March 13, 2024 11:09

@rzarzynski rzarzynski 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.

I very, very like this idea! I hope that ultimately every make check run will happen under valgrind.

I understand there will be a transition period in which we cannot enable (merge) the memcheck because of existing, hidden bugs. This is the main reason behind not approving this immediately.

Comment thread src/CMakeLists.txt 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.

nit: not sure we need to repeat the --suppression here as MEMORYCHECK_SUPPRESSION_FILE is defined below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed and also added some more parameters

@rzarzynski
rzarzynski requested review from cbodley and tchaikov March 13, 2024 11:26
@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch from b2a5ee0 to a5d98ea Compare March 13, 2024 11:36
Comment thread src/CMakeLists.txt Resolved
@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch 2 times, most recently from f2b371b to 2888c2a Compare March 14, 2024 10:04

@tchaikov tchaikov 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.

left a few comments.

Comment thread CMakeLists.txt Resolved
Comment thread CMakeLists.txt 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.

shall we include this module only if WITH_TESTS is enabled?

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.

also, we might want to wire BUILD_TESTING with WITH_TESTS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov can you please clarify what BUILD_TESTING means? i couldn't find it

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.

Comment thread CMakeLists.txt Outdated
Comment on lines 758 to 763

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.

i'd suggest put these settings into a dedicated file under cmake, something like cmake/CTestScript.cmake, which contains:

include(CTest)
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS
  "--trace-children=no --leak-check=full --soname-synonyms=somalloc=*tcmalloc* \
   --child-silent-after-fork=yes")
set(MEMORYCHECK_SUPPRESSIONS_FILE
  "${CMAKE_SOURCE_DIR}/qa/valgrind.supp")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread CMakeLists.txt Resolved
Comment thread src/CMakeLists.txt Resolved
@tchaikov

tchaikov commented Mar 14, 2024 •

Copy link
Copy Markdown
Contributor

I very, very like this idea! I hope that ultimately every make check run will happen under valgrind.

I understand there will be a transition period in which we cannot enable (merge) the memcheck because of existing, hidden bugs. This is the main reason behind not approving this immediately.

i would prefer just running the tests with ASan, and run them with valgrind with a daily cron job. but yeah, if we have the horse machine power to run them for every single PR with valgrind, why not?

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch 3 times, most recently from a4acff4 to 74a2a91 Compare March 14, 2024 14:32
@NitzanMordhai
NitzanMordhai requested a review from tchaikov March 14, 2024 14:32
Adding the option to run the ctest with valgring so we will
be able to find un-initialized variables.
To run the unit-test with memory check:
ctest -R name_test -T memcheck -j 80

Signed-off-by: Nitzan Mordechai <[email protected]>
@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch from 74a2a91 to 5d1753e Compare March 14, 2024 14:35
@cbodley

cbodley commented Mar 14, 2024

Copy link
Copy Markdown
Contributor

i would prefer just running the tests with ASan, and run them with valgrind with a daily cron job. but yeah, if we have the horse machine power to run them for every single PR with valgrind, why not?

i'd love to see asan/ubsan enabled for make check. i've always had trouble getting ceph to start up cleanly with asan enabled though, so i imagine this would be a large project

running under valgrind is a lot slower, especially during startup, so i'd like to see how much longer the checks take when it's enabled. it's important that we have timely feedback on PRs, so i wouldn't want valgrind to add hours to the runtime

@@ -0,0 +1,8 @@
function(build_tests)

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.

sorry for the confusion. i think we can either put the body of this function into this file as it is. and let user to call it like

ctest -S cmake/CTestScript.cmake ...

or just include this file at the top-level CMakeLists.txt. again, i still think it might be better to keep include(CTest) in this file.

Comment thread src/tools/CMakeLists.txt
Comment on lines +27 to +29
if(WITH_TESTS)
add_dependencies(tests neorados)
endif()

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 change can be submitted in another PR.

Comment thread CMakeLists.txt
add_subdirectory(selinux)
endif(WITH_SELINUX)

if(WITH_TESTS)

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 change does not belong to this PR.

@tchaikov

Copy link
Copy Markdown
Contributor

i would prefer just running the tests with ASan, and run them with valgrind with a daily cron job. but yeah, if we have the horse machine power to run them for every single PR with valgrind, why not?

i'd love to see asan/ubsan enabled for make check. i've always had trouble getting ceph to start up cleanly with asan enabled though, so i imagine this would be a large project

i am surprised to learn this actually. does this also apply to our unit tests? or just the servers ? AFAICT, crimson should already be using ASan, as seastar uses ASan when it is built in Debug mode.

running under valgrind is a lot slower, especially during startup, so i'd like to see how much longer the checks take when it's enabled. it's important that we have timely feedback on PRs, so i wouldn't want valgrind to add hours to the runtime

yup, i share the same concern with you.

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch from 499f2a1 to ab2b984 Compare March 24, 2024 10:05
Comment thread cmake/modules/CTestScript.cmake 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.

not sure how far you get, but i ran into a link failure in #56241

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-unittest-with-valgrind branch from ab2b984 to f985a87 Compare March 24, 2024 13:47
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label May 23, 2024
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Jun 22, 2024
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.

4 participants