Opened 7 years ago
Closed 7 years ago
#4534 closed defect (fixed)
Stack overflow in SimCodeUtil.createAllDiffedSimVars
Reported by: | Francesco Casella | Owned by: | Henning Kiel |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | Code Generation | Version: | |
Keywords: | Cc: |
Description
I have a large model with 200.000 equations that gives stack overflow with the standard Linux stack size of 8 MB. The problem is solved by increasing it to 65 MB or more.
[/build/openmodelica-qI4Plt/openmodelica-1.13.0~dev-86-g73d3087/OMCompiler/Compiler/SimCode/SimCodeMain.mo:440:3-440:155:writable] Error: Internal error Stack overflow in SimCodeMain.generateModelCode... [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(Expression.isZero) [bt] #3 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplifyBinaryCommutativeWork) [bt] #4 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplifyBinaryCommutative) [bt] #5 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplifyBinary2) [bt] #6 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplifyBinary) [bt] #7 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplifyWork) [bt] #8...9 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Expression.traverseExpBottomUp) [bt] #10 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplify1FixP) [bt] #11 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplify1WithOptions) [bt] #12 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ExpressionSimplify.simplify1) [bt] #13 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Expression.createResidualExp2) [bt] #14 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Expression.createResidualExp) [bt] #15...1024 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(SimCodeUtil.createNonlinearResidualEquations) [bt] #1025 [...]
I can provide the test case, which is not public, for debugging, but maybe you can catch and remove the bad recursion just based on the stack trace.
Change History (4)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Summary: | Stack overflow in SimCodeUtil.createNonlinearResidualEquations → Stack overflow in SimCodeUtil.createAllDiffedSimVars |
---|
SimCodeUtil.createNonlinearResidualEquations
is now fine, but the stack now overflows on another function (I guess there are many...)
[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(List.fill) [bt] #3 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashSubscripts) [bt] #4 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashComponentRef) [bt] #5 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(ComponentReference.hashComponentRefMod) [bt] #6 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(BackendVariable.getVar2) [bt] #7 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(BackendVariable.getVarSingle) [bt] #8...1024 /usr/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(SimCodeUtil.createAllDiffedSimVars) [bt] #1025 [...]", "TRANSLATION", "Error", "63"}
comment:3 by , 7 years ago
I implemented a fix that avoids recursion in OMCompiler#1844
@casella please test
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
No more stack overflows with this test, even if I reduce the stack size from 8192 to 4000 kB.
Thanks @hkiel!
I implemented a fix that avoids recursion in OMCompiler#1838
@casella please test