You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-dev@incubator.apache.org by "David Wood (JIRA)" <ji...@apache.org> on 2009/03/03 21:38:56 UTC

[jira] Created: (IMPERIUS-23) Infinite loop, and then parse error.

Infinite loop, and then parse error.
------------------------------------

                 Key: IMPERIUS-23
                 URL: https://issues.apache.org/jira/browse/IMPERIUS-23
             Project: Imperius
          Issue Type: Bug
         Environment: Windows, Java 1.5.
            Reporter: David Wood
            Assignee: Bill Stoddard


The following simple policy when parsed causes a hang, which I believe is an infinity look (see below):

Import Class java.util.Properties:prop;
Strategy Execute_All_Applicable;
Policy 
{
	Condition 
	{  
	   1 == 1 && prop.getProperty("foo","bar").equals("foo")
	}
	Decision 
	{   
		prop.getProperty("foo")
	}
}:1;

I found a look in PrimaryExpression.validate() that may not always execute an Iterator.next() as follows:

	        while(identTupleIt.hasNext())
	        {
	        	if(returnType.getType() == TypeConstants.referenceType)
	        	{
	        		String referenceTypeName = returnType.getReferenceTypeName();
	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
	        		if(i++ == 0) // first element in the list has the same symbol table
	        		{ // as the primary expression
	        			ipt.setSymbolTable(_symTab);
	        		}
	        		returnType = ipt.validate(referenceTypeName);
	        	} else {
	        		identTupleIt.next();	// <--- Added by dawood
	        	}
	        	
	        	
	        }

However, this then causes the following exception....

Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
SEVERE: main validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser expr
SEVERE: main TreeParser::Exception creating Expression at line 7 : validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
 validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
Number of Formal and passed parameters don't match for method getProperty
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
SEVERE: Error encountered while parsing tree
Exception in thread "main" org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while parsing tree
	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
	at com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
	at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IMPERIUS-23) Infinite loop, and then parse error.

Posted by "David Wood (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IMPERIUS-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Wood updated IMPERIUS-23:
-------------------------------

    Attachment: Imperius23.java

This Imperius23.java file reproduces the problem and generates the following error message.

Number of Formal and passed parameters don't match for method getProperty

> Infinite loop, and then parse error.
> ------------------------------------
>
>                 Key: IMPERIUS-23
>                 URL: https://issues.apache.org/jira/browse/IMPERIUS-23
>             Project: Imperius
>          Issue Type: Bug
>         Environment: Windows, Java 1.5.
>            Reporter: David Wood
>            Assignee: Bill Stoddard
>         Attachments: Imperius23.java
>
>
> The following simple policy when parsed causes a hang, which I believe is an infinite loop (see below):
> Import Class java.util.Properties:prop;
> Strategy Execute_All_Applicable;
> Policy 
> {
> 	Condition 
> 	{  
> 	   1 == 1 && prop.getProperty("foo","bar").equals("foo")
> 	}
> 	Decision 
> 	{   
> 		prop.getProperty("foo")
> 	}
> }:1;
> I found a loop in PrimaryExpression.validate() that may not always execute an Iterator.next() as follows:
> 	        while(identTupleIt.hasNext())
> 	        {
> 	        	if(returnType.getType() == TypeConstants.referenceType)
> 	        	{
> 	        		String referenceTypeName = returnType.getReferenceTypeName();
> 	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
> 	        		if(i++ == 0) // first element in the list has the same symbol table
> 	        		{ // as the primary expression
> 	        			ipt.setSymbolTable(_symTab);
> 	        		}
> 	        		returnType = ipt.validate(referenceTypeName);
> 	        	} else {
> 	        		identTupleIt.next();	// <--- Added by dawood
> 	        	}
> 	        	
> 	        	
> 	        }
> However, this then causes the following exception....
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
> SEVERE: main validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser expr
> SEVERE: main TreeParser::Exception creating Expression at line 7 : validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
>  validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
> Number of Formal and passed parameters don't match for method getProperty
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
> SEVERE: Error encountered while parsing tree
> Exception in thread "main" org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while parsing tree
> 	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
> 	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
> 	at com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
> 	at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IMPERIUS-23) Infinite loop, and then parse error.

Posted by "David Wood (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IMPERIUS-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Wood updated IMPERIUS-23:
-------------------------------

    Description: 
The following simple policy when parsed causes a hang, which I believe is an infinite loop (see below):

Import Class java.util.Properties:prop;
Strategy Execute_All_Applicable;
Policy 
{
	Condition 
	{  
	   1 == 1 && prop.getProperty("foo","bar").equals("foo")
	}
	Decision 
	{   
		prop.getProperty("foo")
	}
}:1;

I found a loop in PrimaryExpression.validate() that may not always execute an Iterator.next() as follows:

	        while(identTupleIt.hasNext())
	        {
	        	if(returnType.getType() == TypeConstants.referenceType)
	        	{
	        		String referenceTypeName = returnType.getReferenceTypeName();
	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
	        		if(i++ == 0) // first element in the list has the same symbol table
	        		{ // as the primary expression
	        			ipt.setSymbolTable(_symTab);
	        		}
	        		returnType = ipt.validate(referenceTypeName);
	        	} else {
	        		identTupleIt.next();	// <--- Added by dawood
	        	}
	        	
	        	
	        }

However, this then causes the following exception....

Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
SEVERE: main validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser expr
SEVERE: main TreeParser::Exception creating Expression at line 7 : validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
 validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
Number of Formal and passed parameters don't match for method getProperty
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
SEVERE: Error encountered while parsing tree
Exception in thread "main" org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while parsing tree
	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
	at com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
	at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

  was:
The following simple policy when parsed causes a hang, which I believe is an infinity look (see below):

Import Class java.util.Properties:prop;
Strategy Execute_All_Applicable;
Policy 
{
	Condition 
	{  
	   1 == 1 && prop.getProperty("foo","bar").equals("foo")
	}
	Decision 
	{   
		prop.getProperty("foo")
	}
}:1;

I found a look in PrimaryExpression.validate() that may not always execute an Iterator.next() as follows:

	        while(identTupleIt.hasNext())
	        {
	        	if(returnType.getType() == TypeConstants.referenceType)
	        	{
	        		String referenceTypeName = returnType.getReferenceTypeName();
	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
	        		if(i++ == 0) // first element in the list has the same symbol table
	        		{ // as the primary expression
	        			ipt.setSymbolTable(_symTab);
	        		}
	        		returnType = ipt.validate(referenceTypeName);
	        	} else {
	        		identTupleIt.next();	// <--- Added by dawood
	        	}
	        	
	        	
	        }

However, this then causes the following exception....

Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
SEVERE: main validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser expr
SEVERE: main TreeParser::Exception creating Expression at line 7 : validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
 validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
Number of Formal and passed parameters don't match for method getProperty
Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
SEVERE: Error encountered while parsing tree
Exception in thread "main" org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while parsing tree
	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
	at com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
	at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)


> Infinite loop, and then parse error.
> ------------------------------------
>
>                 Key: IMPERIUS-23
>                 URL: https://issues.apache.org/jira/browse/IMPERIUS-23
>             Project: Imperius
>          Issue Type: Bug
>         Environment: Windows, Java 1.5.
>            Reporter: David Wood
>            Assignee: Bill Stoddard
>
> The following simple policy when parsed causes a hang, which I believe is an infinite loop (see below):
> Import Class java.util.Properties:prop;
> Strategy Execute_All_Applicable;
> Policy 
> {
> 	Condition 
> 	{  
> 	   1 == 1 && prop.getProperty("foo","bar").equals("foo")
> 	}
> 	Decision 
> 	{   
> 		prop.getProperty("foo")
> 	}
> }:1;
> I found a loop in PrimaryExpression.validate() that may not always execute an Iterator.next() as follows:
> 	        while(identTupleIt.hasNext())
> 	        {
> 	        	if(returnType.getType() == TypeConstants.referenceType)
> 	        	{
> 	        		String referenceTypeName = returnType.getReferenceTypeName();
> 	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
> 	        		if(i++ == 0) // first element in the list has the same symbol table
> 	        		{ // as the primary expression
> 	        			ipt.setSymbolTable(_symTab);
> 	        		}
> 	        		returnType = ipt.validate(referenceTypeName);
> 	        	} else {
> 	        		identTupleIt.next();	// <--- Added by dawood
> 	        	}
> 	        	
> 	        	
> 	        }
> However, this then causes the following exception....
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
> SEVERE: main validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser expr
> SEVERE: main TreeParser::Exception creating Expression at line 7 : validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
>  validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
> Number of Formal and passed parameters don't match for method getProperty
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
> SEVERE: Error encountered while parsing tree
> Exception in thread "main" org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while parsing tree
> 	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
> 	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
> 	at com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
> 	at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IMPERIUS-23) Infinite loop, and then parse error.

Posted by "David Wood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IMPERIUS-23?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695108#action_12695108 ] 

David Wood commented on IMPERIUS-23:
------------------------------------

The latter exception seems to be happening because the symbol table is a map of only the method name to a MethodSymbol per the following taken from  from JavaDataCollectorImpl._populateClassMethods().

				// construct a method symbol 
				Symbol s = new MethodSymbol(methodName, internalReturnType, isReturnArray, returnReferenceTypeName, argTypeList, null);

				// Insert into map
				symbolMap.put(methodName, s);

Any thoughts on how to address this?  On the parsing side, the code in AnchorMethodInvokeAction only looks at a single symbol returned from the map (which by this time is an SPLSymbolTable and not a simple Map as in the above).

    public static void validateActualParameters(SPLSymbolTable symTab,
            String classNameOrVariableName, String methodName, List pList)
            throws SPLException 
    {
        MethodSymbol methodSym = (MethodSymbol) symTab
                .getSymbol(classNameOrVariableName + "." + methodName);
        List argTypeList = methodSym.getArgumentList();



> Infinite loop, and then parse error.
> ------------------------------------
>
>                 Key: IMPERIUS-23
>                 URL: https://issues.apache.org/jira/browse/IMPERIUS-23
>             Project: Imperius
>          Issue Type: Bug
>         Environment: Windows, Java 1.5.
>            Reporter: David Wood
>            Assignee: Bill Stoddard
>
> The following simple policy when parsed causes a hang, which I believe is an infinite loop (see below):
> Import Class java.util.Properties:prop;
> Strategy Execute_All_Applicable;
> Policy 
> {
> 	Condition 
> 	{  
> 	   1 == 1 && prop.getProperty("foo","bar").equals("foo")
> 	}
> 	Decision 
> 	{   
> 		prop.getProperty("foo")
> 	}
> }:1;
> I found a loop in PrimaryExpression.validate() that may not always execute an Iterator.next() as follows:
> 	        while(identTupleIt.hasNext())
> 	        {
> 	        	if(returnType.getType() == TypeConstants.referenceType)
> 	        	{
> 	        		String referenceTypeName = returnType.getReferenceTypeName();
> 	        		IdentPrimaryTuple ipt = (IdentPrimaryTuple)identTupleIt.next();
> 	        		if(i++ == 0) // first element in the list has the same symbol table
> 	        		{ // as the primary expression
> 	        			ipt.setSymbolTable(_symTab);
> 	        		}
> 	        		returnType = ipt.validate(referenceTypeName);
> 	        	} else {
> 	        		identTupleIt.next();	// <--- Added by dawood
> 	        	}
> 	        	
> 	        	
> 	        }
> However, this then causes the following exception....
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.expressions.impl.LogicalAnd <init>
> SEVERE: main validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.parser.compiler.SPLTreeParser expr
> SEVERE: main TreeParser::Exception creating Expression at line 7 : validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
>  validation error: org.apache.imperius.spl.parser.expressions.impl.LogicalAnd has wrong data type passed in.
> Number of Formal and passed parameters don't match for method getProperty
> Mar 3, 2009 4:35:43 PM org.apache.imperius.spl.datastore.impl.PolicyParserImpl parseFile
> SEVERE: Error encountered while parsing tree
> Exception in thread "main" org.apache.imperius.spl.parser.exceptions.SPLException: Error encountered while parsing tree
> 	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.parseFile(PolicyParserImpl.java:166)
> 	at org.apache.imperius.spl.datastore.impl.PolicyParserImpl.createInternalPolicyObject(PolicyParserImpl.java:96)
> 	at com.ibm.watson.pml.spl.policy.SPLJavaParser.parse(SPLJavaParser.java:47)
> 	at com.ibm.watson.pml.PolicyParser.main(PolicyParser.java:66)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.