#4600 closed defect (fixed)
Internal template error
Reported by: | Rüdiger Franke | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | Susan (Templates) | Version: | |
Keywords: | Cc: | Willi Braun, Martin Sjölund |
Description
Enabling directional derivatives in
OpenModelica/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/testDrumBoiler.mos
with
setCommandLineOptions("+d=-disableDirectionalDerivatives"); getErrorString();
and calling omc results in the following internal error, "which should not happen for functions called from within template code; templates preserve pure 'match'/non-failing semantics":
Error: Template error: A template call failed (a call with 3 parameters: OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so: omc_CodegenFMUCpp_translateModel). One possible reason could be that a template imported function call failed (which should not happen for functions called from within template code; templates preserve pure 'match'/non-failing semantics). Error: Internal error SimCode: The model DrumBoilerModel could not be translated to FMU "
Change History (11)
comment:1 by , 7 years ago
Cc: | added |
---|
comment:2 by , 7 years ago
comment:3 by , 7 years ago
It looks like it might be the listGet
in:
<% varLst |> var as TYPES_VAR(__) hasindex i1 fromindex 2 => let re = daeExp(listGet(expLst,i1), context, &preExp, &varDecls,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation) '<%re%> = <%rec%>.<%var.name%>;' ; separator="\n" %>
comment:4 by , 7 years ago
I'm making a new flag -d=susanDebug
which can generate a different MetaModelica from the Susan code, which can give a stack-trace of the point where the failure happened. You would then need to use that flag to recompile all Susan templates and then get the error at run-time:
[bt] #1 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaRuntimeC.so(mmc_setStacktraceMessages_threadData) [bt] #2 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(StackOverflow.generateReadableMessage) [bt] #3 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Tpl.fakeStackOverflow) [bt] #4...14 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.lm_1582) [bt] #15 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.algStmtAssign) [bt] #16 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.fun_1571) [bt] #17 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.algStatement) [bt] #18...19 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.lm_1573) [bt] #20 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.algStmtWhile) [bt] #21 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.fun_1571) [bt] #22 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.algStatement) [bt] #23...32 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.lm_697) [bt] #33 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.funStatement) [bt] #34 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.functionBodyRegularFunction) [bt] #35 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.fun_422) [bt] #36 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.fun_423) [bt] #37 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.functionBody) [bt] #38...54 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.lm_420) [bt] #55 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.functionBodies) [bt] #56 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.fun_292) [bt] #57 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.simulationFunctionsFile) [bt] #58 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.fun_46) [bt] #59 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenCpp.translateModel) [bt] #60 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(CodegenFMUCpp.translateModel) [bt] #61 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so() [bt] #62 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Tpl.tplCallHandleErrors) [bt] #63 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Tpl.tplCallWithFailError3) [bt] #64 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(Tpl.tplNoret3) [bt] #65 /home/marsj/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so(SimCodeMain.callTargetTemplatesFMU)
Where the only foreign call in CodegenCpp.lm_1582
seems to be listGet
...
comment:5 by , 7 years ago
The error message says "a call with 3 parameters", whereas listGet has 2 arguments!?
follow-up: 8 comment:7 by , 7 years ago
Thank you for pointing to the source of the problem in comment:3. Commit https://github.com/OpenModelica/OMCompiler/commit/32ea34faacf8f95765976c7b0b7001f51246b075 prevents the template error.
Is there really no way to automatically get a better error message if listGet exceeds the size of the list?
Not the complete stack trace, just the error and the location in the template file, something like:
"CodegenCpp.tpl:13220:listGet exceeds size of list"
The current error message appears lordly and is obviously wrong:
"which should not happen for functions called from within template code; templates preserve pure 'match'/non-failing semantics"
Regarding comment:2: What is the meaning of -d
vs +d
? Could I find this somewhere in the docu?
comment:8 by , 7 years ago
Replying to rfranke:
Is there really no way to automatically get a better error message if listGet exceeds the size of the list?
Not the complete stack trace, just the error and the location in the template file, something like:
"CodegenCpp.tpl:13220:listGet exceeds size of list"
By design, no (there is no Error module built-in in MetaModelica; it is a user library). You could write such a function yourself though. List.getWithErrorChecking(lst, n, sourceInfo())
The current error message appears lordly and is obviously wrong:
"which should not happen for functions called from within template code; templates preserve pure 'match'/non-failing semantics"
It is obviously correct; Susan by design assumes that there are no failing functions in the code. Even if an error occurs in the code (calling error()
in a template), it will produce the entire file before printing the error-message and calling fail()
.
Regarding comment:2: What is the meaning of
-d
vs+d
? Could I find this somewhere in the docu?
+d
is the syntax forced on us due to the RML driver; it's been deprecated ever since we switched to the bootstrapped compiler and flags starting with -
were possible to write (although the compiler never warned about the old style being used).
comment:9 by , 7 years ago
Instead of saying "should not happen" ... "by design", a less lordly error message could read:
MetaModelica is not able to produce good error messages and provide good runtime performance at the same time. Please recompile with -d=susanDebug
to get more details about the template error.
comment:10 by , 7 years ago
why not introducing a general approach like for C compilers:
+g verbose debug version, enable susanDebug, etc.
+O debug
+O1 e.g. replace/overload all [] by dangerous_get_array, etc.
comment:11 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
+d=-disableDirectionalDerivatives
really should have been-d=-directionalDerivatives