[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2166) Long "in" lists in queries results in a Java stack overflow exception.

Manuel Dominguez Sarmiento (JIRA) noreply at atlassian.com
Fri Feb 5 23:29:30 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35492#action_35492 ] 

Manuel Dominguez Sarmiento commented on HHH-2166:
-------------------------------------------------

Built 3.5.0 Beta 4 with maven and the test is failing:

-------------------------------------------------------------------------------
Test set: org.hibernate.test.criteria.LongInElementsTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 14.781 sec <<< FAILURE!
testLongInElementsByHQL(org.hibernate.test.criteria.LongInElementsTest)  Time elapsed: 14.64 sec  <<< ERROR!
java.lang.StackOverflowError
	at java.lang.StringBuffer.append(StringBuffer.java:225)
	at antlr.BaseAST.toStringList(BaseAST.java:341)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	at antlr.BaseAST.toStringList(BaseAST.java:347)
	...
	...

> Long "in" lists in queries results in a Java stack overflow exception.
> ----------------------------------------------------------------------
>
>                 Key: HHH-2166
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2166
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0.ga
>         Environment: Hibernate 3.2.0.cr3 through 3.2.0.ga (at least).  Any standard deployment of Sun's JVM on Windows, Linux, or Mac OS X (and presumably other platforms like Solaris)
>            Reporter: Philip R. "Pib" Burns
>            Assignee: Strong Liu
>             Fix For: 3.2.x, 3.3.x, 3.5.0-Beta-3
>
>         Attachments: NodeTraverser.java
>
>   Original Estimate: 1 day
>  Remaining Estimate: 1 day
>
> With Hibernate 320ga a long "in" list can result in a stack overflow error during the parsing stage. For example, a query element like
> where x in (:x)
> or a manually constructed
> where x in (1,2,3 .....)
> can generate a stack overflow if the number of elements referenced by x exceeds a number dependent upon the amount of available stack space. For many JVMs, the limit is between 9,000 and 10,000 assuming a relatively empty stack at the point of query execution. We have applications which occasionally use lists several times this size.
> The stack overflow occurs in org.hibernate.hql.ast.util.NodeTraverser which uses a recursive algorithm to walk a parse tree. Long "in" lists generate a subtree of depth about equal to the number of elements in the list. A sufficiently long list results in a stack overflow when NodeTraverser's internal method visitDepthFirst calls itself too many times.
> The solution is to replace the recursive tree walking strategy with an iterative one that does not use up stack space. I am attaching the source for a replacement version of . NodeTraverser which implements the iterative tree walking method.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list