Bug 755129

Summary: PackageBuilder fails with StackOverflowError if declared model contains recursive data types
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Jiri Locker <jlocker>
Component: BRE (Expert, Fusion)Assignee: Mario Fusco <mfusco>
Status: ASSIGNED --- QA Contact: Jiri Locker <jlocker>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: BRMS 5.3.0.GACC: atangrin, lpetrovi, mproctor, rzhang
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
PackageBuilder fails with the StackOverflowError if the declared model contains recursive data types.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
model-recursive.drl
none
model-circular.drl none

Description Jiri Locker 2011-11-18 22:55:23 UTC
Description of problem:

See attached drl files for sample models. When adding these resources to a KnowledgeBuilder, the compilation fails with java.lang.StackOverflowError.


Version-Release number of selected component (if applicable):
BRMS 5.3.0.DEV5


How reproducible:
always


Steps to Reproduce:
run something like

> Resource res = ResourceFactory.newClassPathResource("model-recursive.drl", getClass());
> KnowledgeBuilderFactory.newKnowledgeBuilder().add(res, ResourceType.DRL);
  

Actual results:
Exception in thread "main" java.lang.StackOverflowError
        at java.util.LinkedList$Entry.<init>(LinkedList.java:787)
        at java.util.LinkedList.addBefore(LinkedList.java:795)
        at java.util.LinkedList.add(LinkedList.java:215)
        at org.drools.compiler.PackageBuilder$Node.accept(PackageBuilder.java:2801)
        at org.drools.compiler.PackageBuilder$Node.accept(PackageBuilder.java:2805)
        ...


Expected results:
PackageBuilder should be able to compile packages with attached models or it should throw an exception if such models are not supported.


Additional info:

Comment 1 Jiri Locker 2011-11-18 22:59:33 UTC
Created attachment 534514 [details]
model-recursive.drl

Comment 2 Jiri Locker 2011-11-18 22:59:56 UTC
Created attachment 534515 [details]
model-circular.drl

Comment 3 JBoss JIRA Server 2012-01-27 20:02:06 UTC
Mario Fusco <mario.fusco> updated the status of jira JBRULES-3229 to Resolved

Comment 4 JBoss JIRA Server 2012-01-27 20:02:06 UTC
Mario Fusco <mario.fusco> made a comment on jira JBRULES-3229

Fixed also for circular type declarations like in:

declare FactA
    fieldB: FactB
end
declare FactB
    fieldA: FactA
end

Comment 5 Ryan Zhang 2012-05-11 01:29:48 UTC
The fix only get in master branch in project  and is not merged in 5.3.x branch, so it is not picked in  the BRMS 5.3 product  branch  as well. 

So Assign back to developer.

Comment 6 Ryan Zhang 2012-05-11 03:43:17 UTC
This issue also has no block+ flag. 
Need PM to decide wanted or not.

Comment 7 Mario Fusco 2012-05-11 06:43:28 UTC
This fix is tightly related with the CompositeKnowledgeBuilder, a brand new feature added in Drools 5.4 that allows to build more cross referencing DRL files at once. I don't think it will be easy to decouple the two, so my advice is to avoid to try to backport this fix unless strictly necessary.

Comment 8 Ryan Zhang 2012-05-11 07:03:18 UTC
In that case, then we can move this to future release.

Comment 9 lcarlon 2012-06-13 03:55:42 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
PackageBuilder fails with StackOverflowError if declared model contains recursive data types.