[
https://issues.jboss.org/browse/JBRULES-3416?page=com.atlassian.jira.plug...
]
Reinis Vicups updated JBRULES-3416:
-----------------------------------
Description:
Given rules lead to (presumed) memmory corruption in some data scenarios:
{code}
package de.orbitx.accumulatetesettest;
import de.orbitx.accumulatesettest.DomainObject;
import de.orbitx.accumulatesettest.Foo;
import de.orbitx.accumulatesettest.Bar;
import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
import org.drools.planner.core.score.constraint.ConstraintType;
global DomainObject aggregator;
rule "reward Bar consolidation"
when
$leftFoo : Foo($leftBar : bar, $leftId : id, $leftInterval : interval)
$rightFoo : Foo(bar == $leftBar, id != $leftId, interval.getStart() <
$leftInterval.getStart())
eval($leftFoo.getInterval().getStart() - $rightFoo.getInterval().getStart() < 4)
then
insertLogical(new IntConstraintOccurrence("reward Bar consolidation",
ConstraintType.POSITIVE, 1, $leftFoo, $rightFoo));
System.out.println("Rewarding leftFoo:" + $leftFoo + " rightFoo:" +
$rightFoo);
end
rule "softConstraintsBroken"
when
$softTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_SOFT, $weight :
weight),
sum($weight))
$positiveSoftTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.POSITIVE, $weight : weight),
sum($weight))
then
aggregator.setValue($softTotal.intValue() - $positiveSoftTotal.intValue());
end
{code}
For instance:
{code}
Foo(id:1, bar:Bar: 0, baz:null, int:Int(start:3, duration:0))
Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
Foo(id:3, bar:Bar: 1, baz:null, int:Int(start:4, duration:0))
Foo(id:4, bar:Bar: 1, baz:null, int:Int(start:2, duration:0))
{code}
session.fireAllRules lead to aggregator.getValue of -2 and following activations
{code}
Rewarding leftFoo:Foo(id:3, bar:Bar: 1, baz:null, int:Int(start:4, duration:0))
rightFoo:Foo(id:4, bar:Bar: 1, baz:null, int:Int(start:2, duration:0))
Rewarding leftFoo:Foo(id:1, bar:Bar: 0, baz:null, int:Int(start:3, duration:0))
rightFoo:Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
{code}
when swapping Bars of Foo 1 and Foo 3:
{code}
Foo(id:1, bar:Bar: 1, baz:null, int:Int(start:3, duration:0))
Foo(id:3, bar:Bar: 0, baz:null, int:Int(start:4, duration:0))
{code}
session.fireAllRules lead to aggregator.getValue of -1 and following activations
{code}
Rewarding leftFoo:Foo(id:3, bar:Bar: 0, baz:null, int:Int(start:4, duration:0))
rightFoo:Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
{code}
Second activation for the Foo 1 and Foo 4 does not happen, thus Geoffreys assumption is
that working memory is corrupted.
was:
Given rules lead to (presumed) memmory corruption in some data scenarios:
package de.orbitx.accumulatetesettest;
import de.orbitx.accumulatesettest.DomainObject;
import de.orbitx.accumulatesettest.Foo;
import de.orbitx.accumulatesettest.Bar;
import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
import org.drools.planner.core.score.constraint.ConstraintType;
global DomainObject aggregator;
rule "reward Bar consolidation"
when
$leftFoo : Foo($leftBar : bar, $leftId : id, $leftInterval : interval)
$rightFoo : Foo(bar == $leftBar, id != $leftId, interval.getStart() <
$leftInterval.getStart())
eval($leftFoo.getInterval().getStart() - $rightFoo.getInterval().getStart() < 4)
then
insertLogical(new IntConstraintOccurrence("reward Bar consolidation",
ConstraintType.POSITIVE, 1, $leftFoo, $rightFoo));
System.out.println("Rewarding leftFoo:" + $leftFoo + " rightFoo:" +
$rightFoo);
end
rule "softConstraintsBroken"
when
$softTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_SOFT, $weight :
weight),
sum($weight))
$positiveSoftTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.POSITIVE, $weight : weight),
sum($weight))
then
aggregator.setValue($softTotal.intValue() - $positiveSoftTotal.intValue());
end
For instance:
Foo(id:1, bar:Bar: 0, baz:null, int:Int(start:3, duration:0))
Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
Foo(id:3, bar:Bar: 1, baz:null, int:Int(start:4, duration:0))
Foo(id:4, bar:Bar: 1, baz:null, int:Int(start:2, duration:0))
session.fireAllRules lead to aggregator.getValue of -2 and following activations
Rewarding leftFoo:Foo(id:3, bar:Bar: 1, baz:null, int:Int(start:4, duration:0))
rightFoo:Foo(id:4, bar:Bar: 1, baz:null, int:Int(start:2, duration:0))
Rewarding leftFoo:Foo(id:1, bar:Bar: 0, baz:null, int:Int(start:3, duration:0))
rightFoo:Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
when swapping Bars of Foo 1 and Foo 3:
Foo(id:1, bar:Bar: 1, baz:null, int:Int(start:3, duration:0))
Foo(id:3, bar:Bar: 0, baz:null, int:Int(start:4, duration:0))
session.fireAllRules lead to aggregator.getValue of -1 and following activations
Rewarding leftFoo:Foo(id:3, bar:Bar: 0, baz:null, int:Int(start:4, duration:0))
rightFoo:Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
Second activation for the Foo 1 and Foo 4 does not happen, thus Geoffreys assumption is
that working memory is corrupted.
WorkingMemory corruption
------------------------
Key: JBRULES-3416
URL:
https://issues.jboss.org/browse/JBRULES-3416
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-compiler (expert), drools-core (expert)
Affects Versions: 5.4.0.Beta2
Environment: linux ubuntu; java version "1.6.0_26"; Java(TM) SE Runtime
Environment (build 1.6.0_26-b03); Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
Reporter: Reinis Vicups
Assignee: Mark Proctor
Given rules lead to (presumed) memmory corruption in some data scenarios:
{code}
package de.orbitx.accumulatetesettest;
import de.orbitx.accumulatesettest.DomainObject;
import de.orbitx.accumulatesettest.Foo;
import de.orbitx.accumulatesettest.Bar;
import org.drools.planner.core.score.constraint.IntConstraintOccurrence;
import org.drools.planner.core.score.constraint.ConstraintType;
global DomainObject aggregator;
rule "reward Bar consolidation"
when
$leftFoo : Foo($leftBar : bar, $leftId : id, $leftInterval : interval)
$rightFoo : Foo(bar == $leftBar, id != $leftId, interval.getStart() <
$leftInterval.getStart())
eval($leftFoo.getInterval().getStart() - $rightFoo.getInterval().getStart() < 4)
then
insertLogical(new IntConstraintOccurrence("reward Bar consolidation",
ConstraintType.POSITIVE, 1, $leftFoo, $rightFoo));
System.out.println("Rewarding leftFoo:" + $leftFoo + " rightFoo:" +
$rightFoo);
end
rule "softConstraintsBroken"
when
$softTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_SOFT, $weight :
weight),
sum($weight))
$positiveSoftTotal : Number() from accumulate(
IntConstraintOccurrence(constraintType == ConstraintType.POSITIVE, $weight : weight),
sum($weight))
then
aggregator.setValue($softTotal.intValue() - $positiveSoftTotal.intValue());
end
{code}
For instance:
{code}
Foo(id:1, bar:Bar: 0, baz:null, int:Int(start:3, duration:0))
Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
Foo(id:3, bar:Bar: 1, baz:null, int:Int(start:4, duration:0))
Foo(id:4, bar:Bar: 1, baz:null, int:Int(start:2, duration:0))
{code}
session.fireAllRules lead to aggregator.getValue of -2 and following activations
{code}
Rewarding leftFoo:Foo(id:3, bar:Bar: 1, baz:null, int:Int(start:4, duration:0))
rightFoo:Foo(id:4, bar:Bar: 1, baz:null, int:Int(start:2, duration:0))
Rewarding leftFoo:Foo(id:1, bar:Bar: 0, baz:null, int:Int(start:3, duration:0))
rightFoo:Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
{code}
when swapping Bars of Foo 1 and Foo 3:
{code}
Foo(id:1, bar:Bar: 1, baz:null, int:Int(start:3, duration:0))
Foo(id:3, bar:Bar: 0, baz:null, int:Int(start:4, duration:0))
{code}
session.fireAllRules lead to aggregator.getValue of -1 and following activations
{code}
Rewarding leftFoo:Foo(id:3, bar:Bar: 0, baz:null, int:Int(start:4, duration:0))
rightFoo:Foo(id:2, bar:Bar: 0, baz:null, int:Int(start:1, duration:0))
{code}
Second activation for the Foo 1 and Foo 4 does not happen, thus Geoffreys assumption is
that working memory is corrupted.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira