Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3659 closed defect (fixed)

Infinite loop in ExpressionSimplify

Reported by: Adrian Pop Owned by: Willi Braun
Priority: high Milestone: 1.9.4
Component: Backend Version:
Keywords: Cc: Vitalij Ruge

Description

Seems these models from ModelicaTest 3.2.1 and ModelicaTest_trunk go into an infinite loop:

ModelicaTest.Fluid.TestComponents.NewFittings.Bends.CurvedBend
ModelicaTest.Fluid.TestComponents.NewFittings.Bends.EdgedBend
ModelicaTest.Fluid.Dissipation.TestCases.PressureLoss.Bend

attaching gdb and doing bt gives you:

#0  0x00007fb26b9e0488 in omc_ExpressionSimplify_simplifyBinary2 ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#1  0x00007fb26b9e6872 in omc_ExpressionSimplify_simplifyBinary ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#2  0x00007fb26b9fd26e in omc_ExpressionSimplify_simplifyWork ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#3  0x00007fb26ba06333 in omc_Expression_traverseExpBottomUp ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#4  0x00007fb26b9f8c28 in omc_ExpressionSimplify_simplify1FixP ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#5  0x00007fb26b9f9102 in omc_ExpressionSimplify_simplify1WithOptions ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#6  0x00007fb26b9fd81a in omc_ExpressionSimplify_simplifyWithOptions ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#7  0x00007fb26b9dc9af in omc_ExpressionSimplify_simplifyRelation2 ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#8  0x00007fb26b9dcd42 in omc_ExpressionSimplify_simplifyRelation ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#9  0x00007fb26b9fd2ef in omc_ExpressionSimplify_simplifyWork ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#10 0x00007fb26ba06333 in omc_Expression_traverseExpBottomUp ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#11 0x00007fb26ba218a9 in omc_Expression_traverseExpList ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#12 0x00007fb26ba05634 in omc_Expression_traverseExpBottomUp ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#13 0x00007fb26ba0554f in omc_Expression_traverseExpBottomUp ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so
#14 0x00007fb26ba0558b in omc_Expression_traverseExpBottomUp ()
   from /var/lib/hudson/jobs/OpenModelica_TEST_ALL_LIBRARIES/workspace/OpenModelica/build/bin/../lib/x86_64-linux-gnu/omc/libOpenModelicaCompiler.so

So it seems to be some loop in ExpressionSimplify or is really really really slow.

Change History (9)

comment:1 by Adrian Pop, 9 years ago

Cc: Vitalij Ruge added

It seems that ExpressionSimplify_simplifyBinaryCommutative somehow gets back to omc_ExpressionSimplify_simplifyBinary2 which gives a cycle.

comment:2 by Adrian Pop, 9 years ago

I think the problematic case is in simplifyBinaryCommutativeWork because it calls simplify1:

    // e1*(e2/e3) => (e1e2)/e3
    case (DAE.MUL(ty = tp),e1,DAE.BINARY(exp1 = e2,operator = DAE.DIV(ty = tp2),exp2 = e3))
      equation
        (e,true) = simplify1(DAE.BINARY(e1,DAE.MUL(tp),e2));
      then DAE.BINARY(e,DAE.DIV(tp2),e3);

Vitalij, can you have a look?

comment:3 by Adrian Pop, 9 years ago

Owner: changed from somebody to Willi Braun
Status: newassigned

in reply to:  2 comment:4 by Vitalij Ruge, 9 years ago

Replying to adrpo:

I think the problematic case is in simplifyBinaryCommutativeWork because it calls simplify1:

    // e1*(e2/e3) => (e1e2)/e3
    case (DAE.MUL(ty = tp),e1,DAE.BINARY(exp1 = e2,operator = DAE.DIV(ty = tp2),exp2 = e3))
      equation
        (e,true) = simplify1(DAE.BINARY(e1,DAE.MUL(tp),e2));
      then DAE.BINARY(e,DAE.DIV(tp2),e3);

maybe, it's a good start point :)

but simplify1(.) is called for e1 and e2. Not for inExp. hence, without e3-> can be a performence issues, because we tranferse the sub-expression of the orginal expression.

Vitalij, can you have a look?

Sure

comment:5 by Willi Braun, 9 years ago

Okay, I've accidental allowed more inline stuff for instance the Fluid function:

ModelicaTest.Fluid.TestComponents.NewFittings.Bends.EdgedBend

what results into an expression that a lot of pages long and than we try to simplify it.

comment:6 by Willi Braun, 9 years ago

Component: FrontendBackend
Resolution: fixed
Status: assignedclosed

That fixes that issue.

comment:7 by Dietmar Winkler, 9 years ago

Milestone: Future1.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.

comment:8 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:9 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.