Skip to content

[CI] Improve Clang-Tidy and kill std::binds#1094

Merged
Skylion007 merged 11 commits intomasterfrom
fix_sensor_memleak
Feb 16, 2021
Merged

[CI] Improve Clang-Tidy and kill std::binds#1094
Skylion007 merged 11 commits intomasterfrom
fix_sensor_memleak

Conversation

@Skylion007
Copy link
Copy Markdown
Contributor

Motivation and Context

  • This fixes a potential memory leak in the Sensor objects and also upgrades clang-tidy to prevent these errors from getting merged in again. The failing test seems unrelated to the PR, oddly enough.

How Has This Been Tested

  • Tested locally on Clang

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 15, 2021
Comment thread .clang-tidy
-clang-analyzer-cplusplus.PlacementNew,
-modernize-avoid-bind,
' # TODO fix std::binds later
# TODO Figure out if PlacementNew is a false positive
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.

.../rapidjson/document.h:1143:21: error: Storage type is aligned to 1 bytes but allocated type is aligned to 8 bytes [clang-analyzer-cplusplus.PlacementNew,-warnings-as-errors]

Sigh. Not a false positive, no. Together with the RapidJson assert that prevents us from reliably running AddressSanitzer I'm starting to feel that we should drop RapidJson and replace it with something that is less of a dumpster fire...

Comment on lines +58 to 59
int nVertex = 0;
iss >> token >> nVertex;
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.

... wait, why a custom PLY parser is still used here? 👀

Copy link
Copy Markdown
Contributor

@erikwijmans erikwijmans Feb 15, 2021

Choose a reason for hiding this comment

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

That's used just for processing the mp3d semantic ply's into what habitat ends up loading. IIRC we left this here because it's used just for that and the mp3d semantic ply's have a whole bunch of weird face attributes instead of our 1 weird one.

Comment thread src/esp/metadata/managers/StageAttributesManager.cpp
Comment thread src/esp/nav/PathFinder.cpp Outdated
Comment thread src/esp/sensor/CameraSensor.cpp Outdated
Comment thread src/esp/sensor/CameraSensor.cpp Outdated
Comment thread src/esp/sim/Simulator.cpp Outdated
Mn::Vector2 nearPlaneSize_ =
Mn::Vector2{1.0f, static_cast<float>(height_) / width_};
float scale;
float scale = NAN;
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.

NAN means not-a-number.
And scale will be used later in nearPlaneSize_ /= scale;
I think scale = 1.0f would be a reasonable initial value.

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.

I would prefer NaN, as scale SHOULD be set. The reason to initially set it as NaN is to know something has gone horribly wrong in the constructor or elsewhere.

Scale will only be user later in nearPlaneSize_ /= scale after being parsed from the config value.

@Skylion007 Skylion007 changed the title [CI] Improve memory leak detection in Clang-Tidy and fix memory leak [CI] Improve Clang-Tidy and kill std::binds Feb 15, 2021
Comment on lines +101 to +103
jsonConfig, "position", [lightAttribs](auto&& PH1) {
lightAttribs->setPosition(std::forward<decltype(PH1)>(PH1));
});
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 is great! Thanks Aaron. I'm going through these and will rewrite the lamdas to be a bit more semantically meaningful.

Copy link
Copy Markdown
Contributor

@jturner65 jturner65 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Skylion007 Skylion007 merged commit 1fb733f into master Feb 16, 2021
@Skylion007 Skylion007 deleted the fix_sensor_memleak branch February 16, 2021 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants