Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Add sanitizing build job #281

Closed
wants to merge 9 commits into from
Closed

Add sanitizing build job #281

wants to merge 9 commits into from

Conversation

HiddenBug
Copy link
Contributor

This PR adds sanitizing as CI jobs to the pilz_robots repository.

.travis.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@agutenkunst agutenkunst left a comment

Choose a reason for hiding this comment

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

Really like having these checks included in the CI. Maybe even interesting for a upstream PR on industrial_ci. Just some minor remarks.

Just as an idea. This would be nice to have as a dedicated package just like https://github.com/mikeferguson/code_coverage for providing a simple macro to enable the sanitizing. However this is far beyond the scope of this PR. Maybe https://github.com/agutenkunst/cmake_extras_demo_pkg could be a starting point.

@agutenkunst agutenkunst self-assigned this Nov 11, 2019
@HiddenBug HiddenBug changed the title WIP: Add sanitizing build job Add sanitizing build job Nov 11, 2019
@HiddenBug
Copy link
Contributor Author

HiddenBug commented Nov 12, 2019

We could split the commits which are only needed to satisfy the clang compiler into a separate PR. @agutenkunst What do you think? See PR #283.

@HiddenBug
Copy link
Contributor Author

HiddenBug commented Nov 12, 2019

For information on how-to execute a sanitizer locally see PR PilzDE/.github#7.

@HiddenBug
Copy link
Contributor Author

As it turns out gcc already supports address and undefined behavior sanitizing (see gcc online documentation).
Furthermore, using clang introduces false-positive error detection's. This seems to happen when a library is not build with clang or something.
There also exists a thread sanitizer but I got a lot of errors using this sanitizer. So I decided to introduce the thread sanitizer later on and just introduce the address and undefined behavior sanitizer in this PR.

Memory sanitizing is only available with clang. However, every dependency needs to be build with the memory sanitizing flags (described for example in the rosproject-scripts repo on GitHub). Therefore, I decided to skip this sanitizer completely (at least for the moment).

GCC provides address and undefined behavior sanitizing.
Memory sanitizing is not included because all dependend libraries need to
be build with memory sanitizing flags, otherwise it comes to
false-positive error detection. Furthermore, memory sanitizing is currently
only supported by clang.
Note: Using clang to sanitize (address or undefined bahvior sanitizing)
leads to false-positive error detections in libraries not build with clang.
Copy link
Contributor

@leunMar leunMar left a comment

Choose a reason for hiding this comment

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

👍 for adding sanitizing

Why not use cmake arguments instead of environment variables for ENABLE_ADDRESS_SANITIZING, etc.?

@HiddenBug
Copy link
Contributor Author

+1 for adding sanitizing

Why not use cmake arguments instead of environment variables for ENABLE_ADDRESS_SANITIZING, etc.?

Good question 😄 I will give it a try.

@HiddenBug
Copy link
Contributor Author

+1 for adding sanitizing

Why not use cmake arguments instead of environment variables for ENABLE_ADDRESS_SANITIZING, etc.?

OK. I only use the travis config file now. This should satisfy you.

@HiddenBug
Copy link
Contributor Author

HiddenBug commented Nov 19, 2019

+1 for adding sanitizing
Why not use cmake arguments instead of environment variables for ENABLE_ADDRESS_SANITIZING, etc.?

OK. I only use the travis config file now. This should satisfy you.

But now I get sanitizing errors in the repositories previously not included 🙈 ARRRRRRRGH... I want to merge.

@HiddenBug
Copy link
Contributor Author

HiddenBug commented Nov 28, 2019

Interesting fact:
The address sanitizer detects a memory leak in libclass_loader, more precisely in /opt/ros/melodic/include/class_loader/class_loader_core.hpp:205 (see Travis log). However, for some reason, maybe because the memory leak detection happens in another process as the test is running in, it does not lead to a test failure. I only see the error output message from the address sanitizer (or more precisely from the LeakSaniatizer).

@martiniil
Copy link
Contributor

Only guessing: from class_loader_core.cpp:

       // Insert into graveyard
        // We remove the metaobject from its factory map, but we don't destroy it...instead it
        // saved to a "graveyard" to the side.
        // This is due to our static global variable initialization problem that causes factories
        // to not be registered when a library is closed and then reopened.
        // This is because it's truly not closed due to the use of global symbol binding i.e.
        // calling dlopen with RTLD_GLOBAL instead of RTLD_LOCAL.
        // We require using the former as the which is required to support RTTI

This "graveyard" is a std::vector holding raw pointers. So maybe that is why these metaobjects are not destroyed.

@martiniil
Copy link
Contributor

I opened an issue: ros/class_loader#131

@martiniil martiniil closed this Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants