Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#4392 closed defect (fixed)

Stack overflow in calculateStrongComponentJacobians

Reported by: Francesco Casella Owned by: Adrian Pop
Priority: high Milestone: 1.12.0
Component: Backend Version:
Keywords: Cc: Per Östlund

Description

When compiling a model with about 200k equations, I get this error during the performance of calculateStrongComponentJacobians:

[/build/openmodelica-pVlUNC/openmodelica-1.12.0~dev-633-gd90ff1c/OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo:6963:3-6963:155:writable] Error: Internal error Stack overflow in BackendDAEUtil.getSolvedSystem...
[bt] #1 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaRuntimeC.so(mmc_setStacktraceMessages_threadData)
[bt] #2 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashSubscript)
[bt] #3 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashSubscripts2)
[bt] #4 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashSubscripts)
[bt] #5 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashComponentRef)
[bt] #6 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashComponentRefMod)
[bt] #7 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(BackendVariable.getVar2)
[bt] #8 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(BackendVariable.getVarSingle)
[bt] #9...1024 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(SymbolicJacobian.createAllDiffedVars)
[bt] #1025 [...]

This happens with the standard 8192 kB stack size. If I increase it to 65535 kB it works fine, but I guess this might be a tell-tale sign of a not-too-efficient implementation.

I can provide the test case separately if needed.

Change History (5)

comment:1 by Henning Kiel, 7 years ago

@casella: Is this still the case? Can you provide an example model?

comment:2 by Henning Kiel, 7 years ago

A quick look:
SymbolicJacobian.createAllDiffedVars is recursive with matchcontinue, so no tail-recursion can be applied.

comment:3 by Henning Kiel, 7 years ago

I implemented a fix that avoids recursion in OMCompiler#1795

comment:4 by Francesco Casella, 7 years ago

Resolution: fixed
Status: newclosed

Problem solved, thanks!

comment:5 by Francesco Casella, 7 years ago

In fact, after some more testing I still got stack overflow, this time on a different function; I opened a separate ticket for that, see #4534.

What is strange is that the first time I ran omc on that test model it worked fine, the second time it failed. Is there such a thing as stack memory leaks?

Note: See TracTickets for help on using tickets.