#3345 closed defect (fixed)
omc crashes with stack overflow
Reported by: | Owned by: | Lennart Ochel | |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.4 |
Component: | Code Generation | Version: | trunk |
Keywords: | Cc: |
Description
Trying to find a workaround for bug #3089 for the HelmholtzMedia library, I slightly changed the inner structure of the model. With this changes omc can flatten the model, but crashes with a stack overflow while generating the simulation code:
Unhandled exception at 0x020992F8 (libOpenModelicaCompiler.dll) in omc.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x00412F58).
One can test it with the test.mos at <https://github.com/AlexanderTaeschner/HelmholtzMedia/tree/master/HelmholtzMedia>.
The command line "c:\OpenModelica1.9.2Nightly\bin\omc.exe +d=dumpdaelow,optdaedump,bltdump,dumpindxdae,backenddaeinfo test.mos > test.log 2>&1" produced the attached "test.log". The used omc version on windows is 1.9.2+dev (r24630).
Attachments (7)
Change History (22)
by , 9 years ago
comment:1 by , 9 years ago
I just retested with the current nightly build for Windows (v1.9.3-dev-790-gb3abd2b) and the result is the same: omc crashes with a stack overflow. (For the tests I had to remove the HelmholtzMedia folder in omlibrary.)
comment:2 by , 9 years ago
Priority: | high → critical |
---|
by , 9 years ago
Attachment: | Test_HeliumTestModel_Total.mos added |
---|
Test script for the save total model.
follow-up: 5 comment:4 by , 9 years ago
I just retested the save total model using the current nightly build (omc version v1.9.3-dev-1199-ge7091b6 without any changes to the installed contents) using
c:\OpenModelica1.9.3Nightly\bin\omc.exe +d=dumpdaelow,optdaedump,bltdump,dumpindxdae,backenddaeinfo Test_HeliumTestModel_Total.mos > log.txt 2>&1
The result is the same: after creating and compiling about 20 C files to 10 dll files the compiler crashes with the following error
Unhandled exception at 0x696C1998 (libOpenModelicaCompiler.dll) in omc.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x00412E08).
If you can't recreate the problem, maybe it would be possible to give me a debug build of the compiler, so that I can create a proper stack trace.
comment:5 by , 9 years ago
Replying to Alexander Täschner <A.Taeschner@…>:
If you can't recreate the problem, maybe it would be possible to give me a debug build of the compiler, so that I can create a proper stack trace.
The Linux build is compiled using -rdynamic and will produce good stack traces.
by , 9 years ago
Attachment: | stacktrace.log added |
---|
comment:6 by , 9 years ago
Cycles over the following functions:
[bt] #174 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateConstantFunctionWrapper+0x12) [0x7faba372b842] [bt] #175 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_Expression_traverseExpTopDown+0x67) [0x7faba3b89c37] [bt] #176 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatement+0x381) [0x7faba3726ab1] [bt] #177 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatementEmptyRepl+0x8d) [0x7faba37266bd] [bt] #178 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateFunctions__updateStatementEmptyRepl+0x15) [0x7faba3728d35] [bt] #179 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_List_mapFold2+0x9d) [0x7faba380dfad] [bt] #180 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_predictIfOutput+0x36c) [0x7faba372623c] [bt] #181 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatement+0x1f09) [0x7faba3728639] [bt] #182 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatementEmptyRepl+0x8d) [0x7faba37266bd] [bt] #183 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(boxptr_EvaluateFunctions_evaluateFunctions__updateStatementEmptyRepl+0x15) [0x7faba3728d35] [bt] #184 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_List_mapFold2+0x9d) [0x7faba380dfad] [bt] #185 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_predictIfOutput+0x36c) [0x7faba372623c] [bt] #186 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatement+0x1f09) [0x7faba3728639] [bt] #187 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateIfStatement+0x529) [0x7faba372c4a9] [bt] #188 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatement+0x1704) [0x7faba3727e34] [bt] #189 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateStatement+0x2427) [0x7faba3728b57] [bt] #190 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateFunctions__updateAlgElements+0x278) [0x7faba372c958] [bt] #191 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_List_mapFold+0x82) [0x7faba380db22] [bt] #192 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateConstantFunction+0x7e7) [0x7faba372acd7] [bt] #193 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(omc_EvaluateFunctions_evaluateConstantFunctionWrapper+0x2d2) [0x7faba372a392]
comment:7 by , 9 years ago
Using the following flags gets further, but the differentiation module also loops:
--preOptModules=unitChecking,evaluateReplaceProtectedFinalEvaluateParameters,stateMachineElab,simplifyIfEquations,expandDerOperator,removeEqualFunctionCalls,clockPartitioning,findStateOrder,introduceDerAlias,inputDerivativesForDynOpt,replaceEdgeChange,inlineArrayEqn,comSubExp,resolveLoops,sortEqnsVars --postOptModules=
I think some function call is recursively inlined, causing the recursion. The differentiation and evaluation modules should have a maximum recursion depth (in addition to some caching mechanism).
comment:8 by , 9 years ago
Fixing the Differentiate module to stop when it detects recursion translates the model (but it does not compile). The following messages are given (probably a derivative annotation is necessary): differentiation.log
by , 9 years ago
Attachment: | differentiation.log added |
---|
comment:9 by , 9 years ago
Thank you for the update! I retestet using the latest Windows nightly with the following results:
- simply running omc on the save total file crashes as before
- using your additional commands produces the internal errors in the differentiation module as you described
- removing the two function redeclares of density_derp_h and density_derh_p (delete lines 2656 to 2708) solve the differentition errors, but still crashes omc (when used without the special flags)
by , 9 years ago
Attachment: | HeliumTestModel_Total_v2.mo added |
---|
Updated save total file for solving the differentiation module problem.
comment:10 by , 9 years ago
I did further tests of the preOptModules and postOptModules. The following default flags lead to a stack overflow if they are added:
- preOptModules: removeSimpleEquations, evalFunc
- postOptModules: removeSimpleEquations
All the other modules together, which are used per default (according to omc.exe --help=optmodules
), generate code, which does not compile due
to undeclared variables.
comment:11 by , 9 years ago
I retested the model using the current Windows nightly (OpenModelica-v1.9.4-dev-94-ge7263fe.exe) with the following results:
- Using the unmodified save total file and no additional flags gives an internal error "Differentiation failed due to recursion".
- Using the modified save total (*_v2*) file and no additional flags does not crash anymore, but the build fails due to undeclared symbols (see log file).
by , 9 years ago
Attachment: | test_total_v2_noflags.log added |
---|
Build log using omc from current nightly without any flags.
comment:12 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:13 by , 9 years ago
Milestone: | Future → 1.9.4 |
---|
Sorting these closed tickets away from "Future". Since they were closed after the last 1.9.3 release, it's very likely that they should have been part of the 1.9.4 release.
Log file