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

CoilCoolingDX::clone crashes when called with another model #4544

Open
jmarrec opened this issue Feb 25, 2022 · 3 comments · May be fixed by #4576
Open

CoilCoolingDX::clone crashes when called with another model #4544

jmarrec opened this issue Feb 25, 2022 · 3 comments · May be fixed by #4576

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Feb 25, 2022

Issue overview

Cloning a CoilCoolingDX crashes when it's cloned to another model.

Steps to Reproduce

m = Model.new
spd_1 = CoilCoolingDXCurveFitSpeed.new(m)
op_mode_base = CoilCoolingDXCurveFitOperatingMode.new(m)
performance_base = CoilCoolingDXCurveFitPerformance.new(m, op_mode_base)
cooling_coil_dx_1 = CoilCoolingDX.new(m, performance_base)

# Ok
cooling_coil_dx_1.clone(m)

m2 = Model.new
# Crash
cooling_coil_dx_1.clone(m2)
[utilities.idf.Workspace] <-1> Unable to add cloned objects to Workspace. The validity report is: 
The collection is INVALID at strictness level 'Draft', because of the errors:
Object     level data error of type NameConflict      .
Error pertains to an object of type 'OS:Coil:Cooling:DX:CurveFit:OperatingMode', named 'Coil Cooling DX Curve Fit Operating Mode 1'.
Additional information about the error type: two objects of the same type or with overlapping references also have the same name.
[utilities.idf.Workspace] <1> Unable to add objectsToAdd and objectsToInsert to their own Workspace as an intermediate step.
[BOOST_ASSERT] <2> Assertion result.size() > 0u failed on line 602 of virtual openstudio::model::ModelObject openstudio::model::detail::ModelObject_Impl::clone(openstudio::model::Model) const in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/model/ModelObject.cpp.
[BOOST_ASSERT] <2> Assertion result.size() > 0u failed on line 602 of virtual openstudio::model::ModelObject openstudio::model::detail::ModelObject_Impl::clone(openstudio::model::Model) const in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/model/ModelObject.cpp.
(pry):8: [BUG] Segmentation fault at 0x0000000000000008
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0026 p:---- s:0136 e:000135 CFUNC  :clone
c:0025 p:0007 s:0131 e:000130 EVAL   (pry):8 [FINISH]
c:0024 p:---- s:0128 e:000127 CFUNC  :eval
c:0023 p:0042 s:0121 e:000120 METHOD /usr/share/rvm/gems/ruby-2.7.2/gems/pry-0.14.1/lib/pry/pry_instance.rb:290
c:0022 p:0240 s:0115 e:000114 METHOD /usr/share/rvm/gems/ruby-2.7.2/gems/pry-0.14.1/lib/pry/pry_instance.rb:659
c:0021 p:0010 s:0104 e:000103 BLOCK  /usr/share/rvm/gems/ruby-2.7.2/gems/pry-0.14.1/lib/pry/pry_instance.rb:261 [FINISH]

Possible Solution

A double clone or mishandling of a required children is the likely cause.

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): all
  • Version of OpenStudio (if using an intermediate build, include SHA): 3.3.0, current develop as well d75af8b

Context

Reported by @j-lorrey

@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 14, 2022

backtrace:

(lldb) bt
* thread #1, name = 'openstudio_mode', stop reason = hit program assert
    frame #0: 0x00007fffefc4903b libc.so.6`raise + 203
    frame #1: 0x00007fffefc28859 libc.so.6`abort + 299
    frame #2: 0x00007fffefc28729 libc.so.6`___lldb_unnamed_symbol8$$libc.so.6 + 15
    frame #3: 0x00007fffefc3a006 libc.so.6`__assert_fail + 70
  * frame #4: 0x0000555555e7029e openstudio_model_tests`boost::assertion_failed(expr="result.size() > 0u", function="virtual openstudio::model::ModelObject openstudio::model::detail::ModelObject_Impl::clone(openstudio::model::Model) const", file="/media/DataExt4/Software/Others/OpenStudio/src/model/ModelObject.cpp", line=602) at Assert.hpp:61:3
    frame #5: 0x00007ffff4191e74 libopenstudiolib.so`openstudio::model::detail::ModelObject_Impl::clone(this=0x0000555557224760, model=Model @ 0x00007fffffffc3a0) const at ModelObject.cpp:602:7
    frame #6: 0x00007ffff48f9008 libopenstudiolib.so`openstudio::model::detail::HVACComponent_Impl::clone(this=0x0000555557224760, model=Model @ 0x00007fffffffc420) const at HVACComponent.cpp:404:43
    frame #7: 0x00007ffff4c96b22 libopenstudiolib.so`openstudio::model::detail::StraightComponent_Impl::clone(this=0x0000555557224760, model=Model @ 0x00007fffffffc4d0) const at StraightComponent.cpp:175:55
    frame #8: 0x00007ffff44bb140 libopenstudiolib.so`openstudio::model::detail::CoilCoolingDX_Impl::clone(this=0x0000555557224760, model=Model @ 0x00007fffffffc540) const at CoilCoolingDX.cpp:112:49
    frame #9: 0x00007ffff4c9743c libopenstudiolib.so`openstudio::model::StraightComponent::clone(this=0x00007fffffffc600, model=Model @ 0x00007fffffffc660) const at StraightComponent.cpp:224:66
    frame #10: 0x0000555555d26ea1 openstudio_model_tests`ModelFixture_CoilCoolingDX_cloneOtherModel_Test::TestBody(this=0x00005555571cfec0) at CoilCoolingDX_GTest.cpp:280:26
    frame #11: 0x0000555556a0fb4e openstudio_model_tests`void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(object=0x00005555571cfec0, method=21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, location="the test body")(), char const*) at gtest.cc:2433:27
    frame #12: 0x0000555556a094b5 openstudio_model_tests`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(object=0x00005555571cfec0, method=21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00, location="the test body")(), char const*) at gtest.cc:2469:52
    frame #13: 0x00005555569e5ade openstudio_model_tests`testing::Test::Run(this=0x00005555571cfec0) at gtest.cc:2508:50
    frame #14: 0x00005555569e64c9 openstudio_model_tests`testing::TestInfo::Run(this=0x00005555571074b0) at gtest.cc:2684:14
    frame #15: 0x00005555569e6c1f openstudio_model_tests`testing::TestSuite::Run(this=0x00005555570df080) at gtest.cc:2816:31
    frame #16: 0x00005555569f2d6f openstudio_model_tests`testing::internal::UnitTestImpl::RunAllTests(this=0x00005555570dede0) at gtest.cc:5338:47
    frame #17: 0x0000555556a10f4d openstudio_model_tests`bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x00005555570dede0, method=52 29 9f 56 55 55 00 00 00 00 00 00 00 00 00 00, location="auxiliary test code (environments or event listeners)")(), char const*) at gtest.cc:2433:27
    frame #18: 0x0000555556a0a509 openstudio_model_tests`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x00005555570dede0, method=52 29 9f 56 55 55 00 00 00 00 00 00 00 00 00 00, location="auxiliary test code (environments or event listeners)")(), char const*) at gtest.cc:2469:52
    frame #19: 0x00005555569f1583 openstudio_model_tests`testing::UnitTest::Run(this=0x0000555557071580) at gtest.cc:4925:55
    frame #20: 0x00005555569c8a02 openstudio_model_tests`RUN_ALL_TESTS() at gtest.h:2473:49
    frame #21: 0x00005555569c8984 openstudio_model_tests`main(argc=1, argv=0x00007fffffffcbd8) at gmock_main.cc:63:23
    frame #22: 0x00007fffefc2a0b3 libc.so.6`__libc_start_main + 243
    frame #23: 0x0000555555accd2e openstudio_model_tests`_start + 46

jmarrec added a commit that referenced this issue Apr 14, 2022
@jmarrec
Copy link
Collaborator Author

jmarrec commented Apr 26, 2022

This boil dows to the fact that we have a situation where we have nested ResourceObjects, and that's perhaps quite unusual.

  • CoilCoolingDX is a StraightComponent, which references,
    • CoilCoolingDXCurveFitPerformance is a ResourceObject, which references:
      • CoilCoolingDXCurveFitOperatingMode is a ResourceObject

The real issue is that CoilCoolingDX references CoilCoolingDXCurveFitPerformance as a child which itself references CoilCoolingDXCurveFitOperatingMode as a child (in the children() method). ResourceObjects should NOT be listed as children. This was only done so the InspectorGadget of the OSApp could pickup the objects. It works fine for the case where you don't have this extra level, but here it creates a crash.

m = Model.new
spd_1 = CoilCoolingDXCurveFitSpeed.new(m)
op_mode_base = CoilCoolingDXCurveFitOperatingMode.new(m)
performance_base = CoilCoolingDXCurveFitPerformance.new(m, op_mode_base)
cooling_coil_dx_1 = CoilCoolingDX.new(m, performance_base)

OpenStudio::Model::getRecursiveResourceSubTrees(cooling_coil_dx_1).map{|r| r.map{|c| c.nameString}}

=> [["Always On Discrete"],
["Coil Cooling DX Curve Fit Performance 1",
 "Coil Cooling DX Curve Fit Operating Mode 1"],
["OnOff"],
["Coil Cooling DX Curve Fit Operating Mode 1"]]

As you can see, the issue is the Coil Cooling DX Curve Fit Operating Mode 1 is present TWICE in that list.

jmarrec added a commit that referenced this issue Jul 26, 2022
jmarrec added a commit that referenced this issue Sep 28, 2022
@tijcolem tijcolem added this to the OpenStudio SDK 3.5.0 milestone Oct 14, 2022
@tijcolem tijcolem removed this from the OpenStudio SDK 3.6.0 milestone Mar 17, 2023
@DavidGoldwasser DavidGoldwasser added this to the OpenStudio SDK 3.7.0 milestone Jun 30, 2023
@DavidGoldwasser
Copy link
Collaborator

Test and confirm this is fixed with latest installer. Confirm there is a unit test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment