-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify sanitizers using IGN_SANITIZERS cmake variable #210
Conversation
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a couple minor comments. I tried it on sdformat and it worked great except the tests that use ign
which gave the error:
ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
I think this is because the libraries are loaded through ruby
when using ign
.
When setting up CI, we'll have to find a way to ignore tests that run ign
.
endif() | ||
append("${SANITIZER_MEM_FLAG}" SANITIZER_SELECTED_FLAGS) | ||
|
||
if(AFL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFL
is not being used here, so we can remove this if
block. Here and elsewhere below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I'm in favor of leave it in place just in the case that someone (or even us in the future) is using that support now that we have it implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'm okay with that, but I haven't tested it. Not sure if you've had a chance.
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Correct, we would need to exclude them somehow when executing the test suite with the sanitizers. Not sure right now that we can do anything for them in this ign-cmake support. |
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Found the place to update the documentation and place a copy of the original docs about how to use the new parameter c1bc190 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. I think we should clarify which CMake variable to use after the latest changes. Also Windows CI is failing.
endif() | ||
append("${SANITIZER_MEM_FLAG}" SANITIZER_SELECTED_FLAGS) | ||
|
||
if(AFL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'm okay with that, but I haven't tested it. Not sure if you've had a chance.
tutorials/ign_cmake_sanitizers.md
Outdated
- [MemorySanitizer](https://clang.llvm.org/docs/MemorySanitizer.html) detects uninitialized reads. | ||
- [Control Flow Integrity](https://clang.llvm.org/docs/ControlFlowIntegrity.html) is designed to detect certain forms of undefined behaviour that can potentially allow attackers to subvert the program's control flow. | ||
|
||
These are used by declaring the `IGN_USE_SANITIZER` CMake variable as string containing any of: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the correct CMake variable is: I see USE_SANITIZER
and IGN_SANITIZER
in the cmake code, but not IGN_USE_SANITIZER
.
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
ok, it is not a good to make changes without caffeine. Sorry for the mess, |
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
||
Note: Address sanitizer may have an impact on the performance of execution. | ||
`IGN_SANITIZER` CMake parameter can be used with different compilers to support the detection of different problems in the code. | ||
[Check the documentation for `IGN_SANITIZER` flag](ign_cmake_sanitizers.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add ign_cmake_sanitizers.md
to tutorials.md.in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem we have is that the ign_cmake_sanitizers
is not really a tutorial but more a documentation on how to use the feature. Not sure if we can consider it as a "tutorial". It is referenced from the "Developing with Ignition CMake" and place inside the tutorials since I did not find a better place for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been using the term "tutorial" to refer to all kinds of documentation, guides, instructions, etc. So I wouldn't worry too much about it. It's good to give the document more visibility by placing it on the main page.
In any case, note that we're not publishing tutorials for ign-cmake
on the main site yet:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @azeey and @chapulina for the information. I added the entry in c55d115
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
* Support for running compiler sanitizers Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org> Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org> Signed-off-by: Harsh Mahesheka <harsh.mahesheka.eee20@iitbhu.ac.in>
This pull request has been mentioned on Gazebo Community. There might be relevant details there: https://community.gazebosim.org/t/new-releases-2022-04-27-fortress-citadel/1389/1 |
🎉 New feature
Part of gazebo-tooling/release-tools#404
Summary
The PR integrates the sanitizers compilers flags into ignition-cmake consumers to facilitate how to run them. It adds a CMake option of
IGN_SANITIZERS
that can be populated with different kind of sanitizers.The work mostly integrated the code from https://github.com/StableCoder/cmake-scripts#sanitizer-builds-sanitizerscmake.
I added a test to run against the FAKE_INSTALL installation that checks that the compiler flag is being added to the compiler when using the CMake parameter.
Test it
It can be used directly without colcon by passing
-DIGN_SANITIZERS=Address
or using colcon together with for example ignition-transport11:colcon build --merge-install --executor sequential --cmake-args -DIGN_SANITIZER=Address -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON --event-handlers console_direct+ colcon test --merge-install
Some tests are failing due to problems with the sanitizer:
Checklist
examples
? I place it under tutorials c1bc190codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.