Skip to content
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

Fix up uninitialized optional in getPastStepValuesForMeasure #5199

Merged
merged 2 commits into from
May 15, 2024

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented May 15, 2024

Pull request overview

old code works with std::optional, but not boost::optional 1.79.0

cf https://gcc.godbolt.org/z/7Khs774rd

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added the Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. label May 15, 2024
@jmarrec jmarrec self-assigned this May 15, 2024
jmarrec added a commit to jmarrec/resstock that referenced this pull request May 15, 2024
@jmarrec jmarrec force-pushed the 5192_getPastStepValuesForMeasure branch from 36de778 to cff0d74 Compare May 15, 2024 19:30
Comment on lines +431 to +435
{
const Json::Value stepValues = runner.getPastStepValuesForMeasure("non_existing");
EXPECT_EQ(0, stepValues.size()); // did not set step result as Success
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Crashing in debug mode before fix, works after

$ Products/openstudio_measure_tests --gtest_filter=*OSRunner_getPastStepValues_step_name_not_initialized*
Running main() from gmock_main.cc
Note: Google Test filter = *OSRunner_getPastStepValues_step_name_not_initialized*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from MeasureFixture
[ RUN      ] MeasureFixture.OSRunner_getPastStepValues_step_name_not_initialized
openstudio_measure_tests: /home/julien/.conan2/p/b/boostfdc6e57e26853/p/include/boost/optional/optional.hpp:1270: boost::optional<T>::reference_type boost::optional<T>::get() [with T = std::__cxx11::basic_string<char>; boost::optional<T>::reference_type = std::__cxx11::basic_string<char>&]: Assertion `this->is_initialized()' failed.
Aborted (core dumped)

@jmarrec jmarrec force-pushed the 5192_getPastStepValuesForMeasure branch 2 times, most recently from a65363a to 879a7b6 Compare May 15, 2024 20:05
…o optional not initialized

```
$ Products/openstudio_measure_tests --gtest_filter=*OSRunner_getPastStepValues_step_name_not_initialized*
Running main() from gmock_main.cc
Note: Google Test filter = *OSRunner_getPastStepValues_step_name_not_initialized*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from MeasureFixture
[ RUN      ] MeasureFixture.OSRunner_getPastStepValues_step_name_not_initialized
openstudio_measure_tests: /home/julien/.conan2/p/b/boostfdc6e57e26853/p/include/boost/optional/optional.hpp:1270: boost::optional<T>::reference_type boost::optional<T>::get() [with T = std::__cxx11::basic_string<char>; boost::optional<T>::reference_type = std::__cxx11::basic_string<char>&]: Assertion `this->is_initialized()' failed.
Aborted (core dumped)
```
old code works with std::optional, but not boost::optional 1.79.0

cf https://gcc.godbolt.org/z/7Khs774rd
@jmarrec jmarrec force-pushed the 5192_getPastStepValuesForMeasure branch from 879a7b6 to 3c4c28d Compare May 15, 2024 20:22
@jmarrec jmarrec merged commit 20d91f5 into develop May 15, 2024
4 of 6 checks passed
@jmarrec jmarrec deleted the 5192_getPastStepValuesForMeasure branch May 15, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Measures Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

runner.getPastStepValuesForMeasure can cause segfault
2 participants