﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5692	"segfault after ""Invalid root""."	john.pye@…	Lennart Ochel	"I have a simulation which fails due to an 'Invalid root' in one of my equations (specifically, trying to solve T(h) for the properties of an incompressible substance, through calls to omc_SolarTherm_Media_SolidParticles_CarboHSP__utilities_T__h).

The output I get from my test script is as follows. We've previously reported the warning messages about the floating-point constant, so that's a different issue. The issue here is something is causing the model executable to segfault here, when it should really just be exiting with an error code (or continuing, even).

Something is apparently causing the solver to segfault from the 'solveNewton' function in libSimulationRuntimeC.so. Surely that isn't intended?

The actually command-line being run here (after compilation of the model) is 

{{{
./PhysicalParticleSystem -override startTime=0.0,stopTime=31536000.0,stepSize=300.0 -s dassl -lv -LOG_SUCCESS,-stdout -f PhysicalParticleSystem_init.xml -r PhysicalParticleSystem_res.mat -nls newton
}}}

The version is OpenModelica 1.15.0~dev-9-g34505da.

And here is the output, including some extra output from the compilation process, wrapper script, etc.:

{{{
<env>john@thunder:~/src/solartherm/tests$ python TestPhysicalParticleSystem.py
Notification: Automatically loaded package Complex 3.2.2 due to uses annotation.
Notification: Automatically loaded package ModelicaServices 3.2.2 due to uses annotation.

[/usr/lib/omlibrary/Modelica 3.2.2/Blocks/Sources.mo:2346:7-2347:66:readonly] Warning: Unused input variable tableAvailable in function .Modelica.Blocks.Sources.CombiTimeTable$data$table.getDerTableValue.
[/usr/lib/omlibrary/Modelica 3.2.2/Blocks/Sources.mo:2312:7-2313:66:readonly] Warning: Unused input variable tableAvailable in function .Modelica.Blocks.Sources.CombiTimeTable$data$table.getTableValue.
[/usr/lib/omlibrary/Modelica 3.2.2/Blocks/Sources.mo:2358:7-2359:66:readonly] Warning: Unused input variable tableAvailable in function .Modelica.Blocks.Sources.CombiTimeTable$data$table.getTableTimeTmin.
[/usr/lib/omlibrary/Modelica 3.2.2/Blocks/Sources.mo:2369:7-2370:66:readonly] Warning: Unused input variable tableAvailable in function .Modelica.Blocks.Sources.CombiTimeTable$data$table.getTableTimeTmax.

PhysicalParticleSystem.c:850:98: warning: magnitude of floating-point constant too large for type 'double'; maximum is 1.7976931348623157E+308 [-Wliteral-range]
    tmp11 = Less(data->localData[0]->realVars[163] /* data.table.nextTimeEventScaled DISCRETE */,1.797693134862316e+308);
                                                                                                 ^
PhysicalParticleSystem.c:851:168: warning: magnitude of floating-point constant too large for type 'double'; maximum is 1.7976931348623157E+308 [-Wliteral-range]
  .../* data.table.nextTimeEvent DISCRETE */ = (tmp11?data->localData[0]->realVars[163] /* data.table.nextTimeEventScaled DISCRETE */:1.797693134862316e+308);
                                                                                                                                      ^
PhysicalParticleSystem_06inz.c:2121:96: warning: magnitude of floating-point constant too large for type 'double'; maximum is 1.7976931348623157E+308 [-Wliteral-range]
  tmp50 = Less(data->localData[0]->realVars[163] /* data.table.nextTimeEventScaled DISCRETE */,1.797693134862316e+308);
                                                                                               ^
PhysicalParticleSystem_06inz.c:2122:166: warning: magnitude of floating-point constant too large for type 'double'; maximum is 1.7976931348623157E+308 [-Wliteral-range]
  .../* data.table.nextTimeEvent DISCRETE */ = (tmp50?data->localData[0]->realVars[163] /* data.table.nextTimeEventScaled DISCRETE */:1.797693134862316e+308);
                                                                                                                                      ^
2 warnings generated.
2 warnings generated.
/usr/bin/../lib/x86_64-linux-gnu/omc/libModelicaMatIO.a(ModelicaMatIO.o): In function `Mat_VarDelete':
(.text+0x1e14): warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp'
assert            | debug   | PhysicalParticleSystem_functions.c:488: Invalid root: (-1991.1)^(0.763767)
assert            | debug   | Solving non-linear system 977 failed at time=9040492.36941685.
|                 | |       | For more information please use -lv LOG_NLS.

Limited backtrace at point of segmentation fault
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7ffbb01af390]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(solveNewton+0xda)[0x7ffbb1617385]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(solveNLS+0xb1)[0x7ffbb15f8b05]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(solve_nonlinear_system+0x307)[0x7ffbb15f9057]
./PhysicalParticleSystem(PhysicalParticleSystem_eqFunction_977+0x7f)[0x41ade3]
./PhysicalParticleSystem(PhysicalParticleSystem_functionDAE+0x496)[0x41d676]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(updateDiscreteSystem+0x83)[0x7ffbb1605d0b]
./PhysicalParticleSystem(PhysicalParticleSystem_performSimulation+0xcca)[0x41773a]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(solver_main+0x302)[0x7ffbb160d669]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(+0x86921)[0x7ffbb1632921]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(startNonInteractiveSimulation+0x9f4)[0x7ffbb1631cec]
/usr/bin/../lib/x86_64-linux-gnu/omc/libSimulationRuntimeC.so(_main_SimulationRuntime+0x73)[0x7ffbb1634181]
./PhysicalParticleSystem(main+0x1ac)[0x41e613]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ffbafdf4830]
./PhysicalParticleSystem(_start+0x29)[0x416999]
E
======================================================================
ERROR: test_sched (__main__.TestPhysicalParticleSystem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""TestPhysicalParticleSystem.py"", line 28, in test_sched
    sim.simulate(start=0, stop='1y', step='5m',solver='dassl', nls='newton')
  File ""/home/john/.local/lib/python2.7/site-packages/solartherm/simulation.py"", line 360, in simulate
    sp.check_call(['./'+self.model] + sim_args + args)
  File ""/usr/lib/python2.7/subprocess.py"", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '['./PhysicalParticleSystem', '-override', 'startTime=0.0,stopTime=31536000.0,stepSize=300.0', '-s', 'dassl', '-lv', '-LOG_SUCCESS,-stdout', '-f', 'PhysicalParticleSystem_init.xml', '-r', 'PhysicalParticleSystem_res.mat', '-nls', 'newton']' returned non-zero exit status -11

----------------------------------------------------------------------
Ran 1 test in 5.896s

FAILED (errors=1)
}}}
"	defect	closed	high	1.16.0	Run-time	v.1.15.0-dev	invalid		
