[Jastadd] Fwd: Possible bug in circular attribute

From: Johan Akesson <johan.akesson_at_control.lth.se>
Date: Wed, 18 Jan 2012 09:39:13 +0100

Dear all,

the potential JastAdd bug reported by Jesper M. on January 2 has turned out to be critical (practically a blocker) for us: <https://trac.jmodelica.org/ticket/1736>.

Is there any chance that someone can have a look at this to help us understand what is going on?

Best regards
/Johan

Begin forwarded message:

> From: Jesper Mattsson <jesper.mattsson_at_modelon.com>
> Date: January 2, 2012 11:01:53 AM GMT+01:00
> To: "jastadd_at_cs.lth.se" <jastadd_at_cs.lth.se>
> Subject: [Jastadd] Possible bug in circular attribute
>
> Hi
>
> In the JModelica.org compiler, we have a circular attribute InstDot.myInstClassDecl() that under certain circumstances gives strange results. (I have a test case that provokes it, but it is a complicated one.) I think that this is a bug in JastAdd.
>
> The attribute in question is lazy and circular. When the bug occurs, then:
> · myInstClassDecl _computed = false
> · myInstClassDecl _initialized = false
> · myInstClassDecl_visited = -1
> · in$Circle = false
> · is$Final = true
> · result of state() looks like ("Copy Variables" in Eclipse debug):
> state ASTNode$State (id=1360)
> boundariesCrossed 0 [0x0]
> CHANGE false
> CIRCLE_INDEX 1053 [0x41d]
> circularEvalSet LinkedHashSet<E> (id=1362)
> circularEvalStack Stack<E> (id=1369)
> capacityIncrement 0 [0x0]
> elementCount 4 [0x4]
> elementData Object[10] (id=1385)
> [0] ASTNode$State$CircularStackEntry (id=1386)
> [1] ASTNode$State$CircularStackEntry (id=1387)
> [2] ASTNode$State$CircularStackEntry (id=1388)
> [3] ASTNode$State$CircularStackEntry (id=1389)
> [4] null
> …
> modCount 63576 [0xf858]
> duringConnections 0 [0x0]
> duringFlatTypeAnalysis 0 [0x0]
> duringInitialTransformations 0 [0x0]
> duringInstFunctionBinding 0 [0x0]
> duringInstNameClassification 0 [0x0]
> duringPredefinedTypes 0 [0x0]
> duringScalarization 0 [0x0]
> duringTransformCanonical 0 [0x0]
> IN_CIRCLE true
> LAST_CYCLE true
> pos 0 [0x0]
> RESET_CYCLE false
> stack (id=1402)
>
> This leads to the following code being executed:
> if (!myInstClassDecl_initialized) {
> myInstClassDecl_initialized = true;
> myInstClassDecl_value = unknownInstClassDecl();
> }
> if (!state.IN_CIRCLE) {
> // This is not executed
> }
> if(myInstClassDecl_visited != state.CIRCLE_INDEX) {
> myInstClassDecl_visited = state.CIRCLE_INDEX;
> if (state.LAST_CYCLE) {
> myInstClassDecl_computed = true;
> return myInstClassDecl_compute();
> }
>
> Thus myInstClassDecl_value is set to the initialization value, myInstClassDecl _computed is set to true, and the correct value is calculated and returned, but never saved in myInstClassDecl_value.
> The next time myInstClassDecl() is called (right after the first call, due to being called from a circular attribute), then the initialization value is returned immediately.
>
>
> That's all the information I can think of – anything else?
>
> Jesper
>
> Jesper MATTSSON, MSc
> Software Developer & IT Administrator
>
> Phone direct: +46 73 324 5909
> Email: jesper.mattsson_at_modelon.com
>
>
> Modelon AB
> Ideon Science Park
> SE-223 70 Lund, Sweden
> Phone: +46 46 286 2200
> Fax: +46 46 286 2201
>
> Web: http://www.modelon.com
>
>
> _______________________________________________
> JastAdd mailing list
> JastAdd_at_cs.lth.se
> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd

Johan Åkesson, PhD, Assistant Professor
Deptm. of Automatic Control E-mail: johan.akesson_at_control.lth.se
Faculty of Engineering WWW: www.control.lth.se/user/jakesson
Lund University Phone: +46 46 2228797
Box 118 Fax: +46 46 138118
221 00 LUND
Received on Wed Jan 18 2012 - 09:39:24 CET

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST