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

OS 3.6 segmentation fault #4882

Closed
shorowit opened this issue May 10, 2023 · 2 comments · Fixed by #4884
Closed

OS 3.6 segmentation fault #4882

shorowit opened this issue May 10, 2023 · 2 comments · Fixed by #4884

Comments

@shorowit
Copy link
Contributor

shorowit commented May 10, 2023

Issue overview

Occurs w/ ResStock updated to using OpenStudio 3.6.

[BOOST_ASSERT] <2> Assertion m_impl failed on line 2031 of openstudio::IdfObject::IdfObject(const openstudio::IdfObject&) in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/utilities/idf/IdfObject.cpp.
[BOOST_ASSERT] <2> Assertion m_impl failed on line 2031 of openstudio::IdfObject::IdfObject(const openstudio::IdfObject&) in file /srv/jenkins/openstudio/git/nightly/ubuntu_2004/src/utilities/idf/IdfObject.cpp.
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/model.rb:124: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0016 p:---- s:0119 e:000118 CFUNC  :translateModel
c:0015 p:0124 s:0114 e:000113 METHOD :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/model.rb:124
c:0014 p:0240 s:0102 E:000fd0 METHOD :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/jobs/run_translation.rb:72
c:0013 p:0084 s:0096 e:000095 METHOD :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:291
c:0012 p:0041 s:0088 e:000087 METHOD :/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:233
c:0011 p:1045 s:0082 E:0026b0 METHOD :/openstudio_cli.rb:1187
c:0010 p:0256 s:0062 e:000061 METHOD :/openstudio_cli.rb:817
c:0009 p:0605 s:0055 E:002408 EVAL   :/openstudio_cli.rb:1984 [FINISH]
c:0008 p:---- s:0049 e:000048 CFUNC  :eval
c:0007 p:0074 s:0042 e:000041 METHOD eval:188
c:0006 p:0060 s:0033 e:000032 BLOCK  eval:173 [FINISH]
c:0005 p:---- s:0028 e:000027 CFUNC  :each
c:0004 p:0015 s:0024 e:000023 METHOD eval:167
c:0003 p:0331 s:0018 e:000017 METHOD eval:126
c:0002 p:0005 s:0007 e:000006 EVAL   eval:3 [FINISH]
c:0001 p:0000 s:0003 E:0003d0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
eval:3:in `<main>'
eval:126:in `require'
eval:167:in `require_embedded'
eval:167:in `each'
eval:173:in `block in require_embedded'
eval:188:in `require_embedded_absolute'
eval:188:in `eval'
:/openstudio_cli.rb:1984:in `<main>'
:/openstudio_cli.rb:817:in `execute'
:/openstudio_cli.rb:1187:in `execute'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:233:in `run'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:291:in `step'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/jobs/run_translation.rb:72:in `perform'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/model.rb:124:in `translate_to_energyplus'
:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/model.rb:124:in `translateModel'

Steps to Reproduce

The simplest example I can provide starts with an HPXML file:

  1. Clone https://github.com/NREL/OpenStudio-HPXML
  2. Download these HPXML and OSW files to the top-level dir of the repo.
  3. Run openstudio run -w run-hpxml.osw and observe segmentation fault.

But it's really bizarre. The simulation will work successfully if I make quite a few different changes to the HXPML file. For example

  1. Remove use of ScheduleFile for occupancy (remove <SchedulesFilePath>schedules.csv</SchedulesFilePath> in the HPXML)
  2. Change the cooling system fraction load met (change <FractionCoolLoadServed>0.6</FractionCoolLoadServed> to <FractionCoolLoadServed>1.0</FractionCoolLoadServed> in the HPXML)
  3. Remove all the ventilation fans (remove the entire <MechanicalVentilation>...</MechanicalVentilation> section in the HPXML)

Since these changes are all very different in terms of what model objects they touch, it seems like the segmentation fault somehow requires this particular combination of model objects.

Details

Environment

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

  • WSL (Ubuntu 20.04)
  • OpenStudio 3.6.0+860f5de185
@shorowit shorowit added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label May 10, 2023
@jmarrec
Copy link
Collaborator

jmarrec commented May 10, 2023

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #0: 0x0000000196db8724 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000196defc28 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x0000000196cfdae8 libsystem_c.dylib`abort + 180
    frame #3: 0x0000000196cfce44 libsystem_c.dylib`__assert_rtn + 272
  * frame #4: 0x0000000100008294 openstudio`boost::assertion_failed(expr="m_impl", function="openstudio::IdfObject::IdfObject(const openstudio::IdfObject &)", file="/Users/julien/Software/Others/OpenStudio/src/utilities/idf/IdfObject.cpp", line=2031) at Assert.hpp:61:3
    frame #5: 0x00000001111801ec libopenstudiolib.dylib`openstudio::IdfObject::IdfObject(this=0x000000016fdf0bd0, other=0x000000012403afe8) at IdfObject.cpp:2031:3
    frame #6: 0x000000011118024c libopenstudiolib.dylib`openstudio::IdfObject::IdfObject(this=0x000000016fdf0bd0, other=0x000000012403afe8) at IdfObject.cpp:2030:69
    frame #7: 0x0000000111161bfc libopenstudiolib.dylib`boost::optional_detail::optional_base<openstudio::IdfObject>::construct(this=0x000000016fdf0bc8, val=0x000000012403afe8) at optional.hpp:409:36
    frame #8: 0x0000000112cfef6c libopenstudiolib.dylib`boost::optional_detail::optional_base<openstudio::IdfObject>::optional_base(this=0x000000016fdf0bc8, (null)=init_value_tag @ 0x000000016fdedeef, val=0x000000012403afe8) at optional.hpp:163:9
    frame #9: 0x0000000112cfef34 libopenstudiolib.dylib`boost::optional<openstudio::IdfObject>::optional(this=0x000000016fdf0bc8, val=0x000000012403afe8) at optional.hpp:938:38
    frame #10: 0x0000000112ca5350 libopenstudiolib.dylib`boost::optional<openstudio::IdfObject>::optional(this=0x000000016fdf0bc8, val=0x000000012403afe8) at optional.hpp:938:83
    frame #11: 0x0000000112cb8acc libopenstudiolib.dylib`openstudio::energyplus::ForwardTranslator::createFluidProperties(this=0x0000600003db5950, glycolType="PropyleneGlycol", glycolConcentration=50) at ForwardTranslator.cpp:4518:12
    frame #12: 0x0000000112dff994 libopenstudiolib.dylib`openstudio::energyplus::ForwardTranslator::translatePlantLoop(this=0x0000600003db5950, plantLoop=0x000000016fdf3288) at ForwardTranslatePlantLoop.cpp:496:56
    frame #13: 0x0000000112c92530 libopenstudiolib.dylib`openstudio::energyplus::ForwardTranslator::translateAndMapModelObject(this=0x0000600003db5950, modelObject=0x000060000123bfd8) at ForwardTranslator.cpp:2235:18
    frame #14: 0x0000000112c87f84 libopenstudiolib.dylib`openstudio::energyplus::ForwardTranslator::translateModelPrivate(this=0x0000600003db5950, model=0x000000016fdfb1d8, fullModelTranslation=true) at ForwardTranslator.cpp:615:7
    frame #15: 0x0000000112c83e68 libopenstudiolib.dylib`openstudio::energyplus::ForwardTranslator::translateModel(this=0x0000600003db5950, model=0x000060000029c960, progressBar=0x0000000000000000) at ForwardTranslator.cpp:145:12
    frame #16: 0x000000013b808988 librubyengine.so`_wrap_ForwardTranslator_translateModel__SWIG_1(argc=1, argv=0x0000000128008398, self=4417963760) at ruby_OpenStudioEnergyPlus_wrap.cxx:7203:24
    frame #17: 0x000000013b7fe25c librubyengine.so`_wrap_ForwardTranslator_translateModel(nargs=1, args=0x0000000128008398, self=4417963760) at ruby_OpenStudioEnergyPlus_wrap.cxx:7236:16
    frame #18: 0x000000013c05c2a8 librubyengine.so`vm_call_cfunc [inlined] vm_call_cfunc_with_frame(ec=0x0000000100e04440, reg_cfp=0x0000000128107cb8, calling=<unavailable>, cd=<unavailable>, empty_kw_splat=<unavailable>) at vm_insnhelper.c:2514:11
    frame #19: 0x000000013c05c1e4 librubyengine.so`vm_call_cfunc(ec=0x0000000100e04440, reg_cfp=0x0000000128107cb8, calling=<unavailable>, cd=<unavailable>) at vm_insnhelper.c:2539:12
    frame #20: 0x000000013c0444dc librubyengine.so`vm_exec_core [inlined] vm_sendish(ec=0x0000000100e04440, reg_cfp=<unavailable>, cd=0x0000000102256570, block_handler=0, method_explorer=<unavailable>) at vm_insnhelper.c:4023:11
    frame #21: 0x000000013c0444a0 librubyengine.so`vm_exec_core(ec=<unavailable>, initial=<unavailable>) at insns.def:801:11
    frame #22: 0x000000013c057bac librubyengine.so`rb_vm_exec(ec=0x0000000100e04440, mjit_enable_p=<unavailable>) at vm.c:0:21
    frame #23: 0x000000013c05213c librubyengine.so`rb_f_eval [inlined] eval_string_with_scope(scope=4329597080, src=<unavailable>, file=<unavailable>, line=<unavailable>) at vm_eval.c:1648:12
    frame #24: 0x000000013c051f88 librubyengine.so`rb_f_eval(argc=<unavailable>, argv=<unavailable>, self=<unavailable>) at vm_eval.c:1691:9
    frame #25: 0x000000013c05c2a8 librubyengine.so`vm_call_cfunc [inlined] vm_call_cfunc_with_frame(ec=0x0000000100e04440, reg_cfp=0x0000000128107e78, calling=<unavailable>, cd=<unavailable>, empty_kw_splat=<unavailable>) at vm_insnhelper.c:2514:11
    frame #26: 0x000000013c05c1e4 librubyengine.so`vm_call_cfunc(ec=0x0000000100e04440, reg_cfp=0x0000000128107e78, calling=<unavailable>, cd=<unavailable>) at vm_insnhelper.c:2539:12
    frame #27: 0x000000013c0444dc librubyengine.so`vm_exec_core [inlined] vm_sendish(ec=0x0000000100e04440, reg_cfp=<unavailable>, cd=0x0000000100e1a350, block_handler=0, method_explorer=<unavailable>) at vm_insnhelper.c:4023:11
    frame #28: 0x000000013c0444a0 librubyengine.so`vm_exec_core(ec=<unavailable>, initial=<unavailable>) at insns.def:801:11
    frame #29: 0x000000013c057bac librubyengine.so`rb_vm_exec(ec=0x0000000100e04440, mjit_enable_p=<unavailable>) at vm.c:0:21
    frame #30: 0x000000013c0652d8 librubyengine.so`invoke_block_from_c_bh [inlined] invoke_block(ec=<unavailable>, iseq=<unavailable>, self=<unavailable>, captured=<unavailable>, cref=<unavailable>, type=<unavailable>, opt_pc=<unavailable>) at vm.c:1044:12 [artificial]
    frame #31: 0x000000013c051184 librubyengine.so`rb_yield(val=<unavailable>) at vm_eval.c:0
    frame #32: 0x000000013be3f0a0 librubyengine.so`rb_ary_each(ary=4328978280) at array.c:2135:2
    frame #33: 0x000000013c05c2a8 librubyengine.so`vm_call_cfunc [inlined] vm_call_cfunc_with_frame(ec=0x0000000100e04440, reg_cfp=0x0000000128107f20, calling=<unavailable>, cd=<unavailable>, empty_kw_splat=<unavailable>) at vm_insnhelper.c:2514:11
    frame #34: 0x000000013c05c1e4 librubyengine.so`vm_call_cfunc(ec=0x0000000100e04440, reg_cfp=0x0000000128107f20, calling=<unavailable>, cd=<unavailable>) at vm_insnhelper.c:2539:12
    frame #35: 0x000000013c044394 librubyengine.so`vm_exec_core [inlined] vm_sendish(ec=0x0000000100e04440, reg_cfp=<unavailable>, cd=0x0000600003315450, block_handler=<unavailable>, method_explorer=<unavailable>) at vm_insnhelper.c:4023:11
    frame #36: 0x000000013c044350 librubyengine.so`vm_exec_core(ec=<unavailable>, initial=<unavailable>) at insns.def:782:11
    frame #37: 0x000000013c057bac librubyengine.so`rb_vm_exec(ec=0x0000000100e04440, mjit_enable_p=<unavailable>) at vm.c:0:21
    frame #38: 0x00000001364e1850 librubyengine.so`openstudio::evaluateSimpleImpl(arg=4331471880) at RubyEval.hpp:10:10
    frame #39: 0x000000013beccf30 librubyengine.so`rb_protect(proc=<unavailable>, data=<unavailable>, pstate=<unavailable>) at eval.c:1087:2
    frame #40: 0x00000001364e04e8 librubyengine.so`openstudio::evalString(t_str="\n       begin\n         require 'openstudio_cli'\n       rescue Exception => e\n         puts\n         puts \"Error: #{e.message}\"\n         puts \"Backtrace:\\n\\t\" + e.backtrace.join(\"\\n\\t\")\n         raise\n       end\n     ") at RubyEval.hpp:17:18
    frame #41: 0x000000013bcc3cdc librubyengine.so`openstudio::RubyEngine::exec(this=0x000060000211c5f0, sv="\n       begin\n         require 'openstudio_cli'\n       rescue Exception => e\n         puts\n         puts \"Error: #{e.message}\"\n         puts \"Backtrace:\\n\\t\" + e.backtrace.join(\"\\n\\t\")\n         raise\n       end\n     ") at RubyEngine.cpp:82:40
    frame #42: 0x000000010015ae0c openstudio`openstudio::rubyCLI(rubyEngine=0x000000016fdfdc08) at RubyCLI.cpp:9:17
    frame #43: 0x00000001000d7724 openstudio`main(argc=4, argv=0x000000016fdfdf10) at main.cpp:326:14
    frame #44: 0x0000000196a97f28 dyld`start + 2236

@jmarrec
Copy link
Collaborator

jmarrec commented May 10, 2023

My fault, another case of a double emplace invalidating the iterator here:

// TODO: JM 2019-03-22 I am not sure you need this one
// But I temporarily removed the \reference FluidAndGlycolNames from FluidProperties_GlycolConcentration to avoid problems of having two objects of
// the same reference group bearing the same name (FluidProperties:Name also has the same reference group)
IdfObject& fluidPropName = m_idfObjects.emplace_back(openstudio::IddObjectType::FluidProperties_Name);
fluidPropName.setString(FluidProperties_NameFields::FluidName, glycolName);
fluidPropName.setString(FluidProperties_NameFields::FluidType, "Glycol");
IdfObject& fluidPropGlyConcentration = m_idfObjects.emplace_back(openstudio::IddObjectType::FluidProperties_GlycolConcentration);
fluidPropGlyConcentration.setName(glycolName);
fluidPropGlyConcentration.setString(FluidProperties_GlycolConcentrationFields::GlycolType, glycolType);
fluidPropGlyConcentration.setDouble(FluidProperties_GlycolConcentrationFields::GlycolConcentration, glycolConcentration * 0.01);
return fluidPropName;

jmarrec added a commit that referenced this issue May 10, 2023
jmarrec added a commit that referenced this issue May 10, 2023
jmarrec added a commit that referenced this issue May 10, 2023
jmarrec added a commit that referenced this issue May 10, 2023
@jmarrec jmarrec added severity - Normal Bug component - IDF Translation and removed Triage Issue needs to be assessed and labeled, further information on reported might be needed labels May 10, 2023
@jmarrec jmarrec self-assigned this May 10, 2023
jmarrec added a commit that referenced this issue May 11, 2023
jmarrec added a commit that referenced this issue May 11, 2023
tijcolem added a commit that referenced this issue May 12, 2023
Fix #4882 - Avoid a crash in createFluidProperties during FT that's due to Undefined Behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants