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 #4882 - Avoid a crash in createFluidProperties during FT that's due to Undefined Behavior #4884

Merged
merged 2 commits into from
May 12, 2023

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented May 10, 2023

Pull request overview

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 severity - Normal Bug component - IDF Translation Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels May 10, 2023
@jmarrec jmarrec self-assigned this May 10, 2023
Comment on lines +174 to +189
TEST_F(EnergyPlusFixture, ForwardTranslator_PlantLoop_createFluidProperties) {
// test for #4482 - It crashes with 5 plantloops

for (int n = 1; n <= 10; ++n) {
Model m;

for (int i = 0; i < n; ++i) {
PlantLoop p(m);
EXPECT_TRUE(p.setFluidType("PropyleneGlycol"));
EXPECT_TRUE(p.setGlycolConcentration(50 + i));
}
ForwardTranslator ft;
// EXPECT_TRUE(false) << "Failed for " << n << " PlantLoops";
ASSERT_NO_THROW(ft.translateModel(m)) << "Failed for " << n << " PlantLoops";
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before fix it crashes at 5 PlantLoops

[ RUN      ] EnergyPlusFixture.ForwardTranslator_PlantLoop_createFluidProperties
/Users/julien/Software/Others/OpenStudio/src/energyplus/Test/PlantLoop_GTest.cpp:186: Failure
Value of: false
  Actual: false
Expected: true
Failed for 1 PlantLoops
/Users/julien/Software/Others/OpenStudio/src/energyplus/Test/PlantLoop_GTest.cpp:186: Failure
Value of: false
  Actual: false
Expected: true
Failed for 2 PlantLoops
/Users/julien/Software/Others/OpenStudio/src/energyplus/Test/PlantLoop_GTest.cpp:186: Failure
Value of: false
  Actual: false
Expected: true
Failed for 3 PlantLoops
/Users/julien/Software/Others/OpenStudio/src/energyplus/Test/PlantLoop_GTest.cpp:186: Failure
Value of: false
  Actual: false
Expected: true
Failed for 4 PlantLoops
/Users/julien/Software/Others/OpenStudio/src/energyplus/Test/PlantLoop_GTest.cpp:186: Failure
Value of: false
  Actual: false
Expected: true
Failed for 5 PlantLoops
[BOOST_ASSERT] <2> Assertion m_impl failed on line 2031 of openstudio::IdfObject::IdfObject(const openstudio::IdfObject &) in file /Users/julien/Software/Others/OpenStudio/src/utilities/idf/IdfObject.cpp.
Assertion failed: (false), function assertion_failed, file Assert.hpp, line 61.


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.49 sec

The following tests FAILED:
        2890 - EnergyPlusFixture.ForwardTranslator_PlantLoop_createFluidProperties (Subprocess aborted)

Comment on lines +4514 to +4519
// NOTE: do not do another emplace_back before returning
IdfObject& fluidPropName = m_idfObjects.emplace_back(openstudio::IddObjectType::FluidProperties_Name);
fluidPropName.setString(FluidProperties_NameFields::FluidName, glycolName);
fluidPropName.setString(FluidProperties_NameFields::FluidType, "Glycol");

return {fluidPropName};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fix here

@joseph-robertson
Copy link
Collaborator

I tested the Ubuntu 22.04 installer locally on WSL2, and it seems to correct the issue.

@tijcolem tijcolem merged commit 53176d7 into develop May 12, 2023
@tijcolem tijcolem deleted the 4882_fluidProperties_UB branch May 12, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - IDF Translation Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. severity - Normal Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OS 3.6 segmentation fault
4 participants