Bug 1119308

Summary: java-1.8.0-openjdk: Infinite recursion in java.util.regex.Pattern
Product: [Fedora] Fedora Reporter: Mikolaj Izdebski <mizdebsk>
Component: java-1.8.0-openjdkAssignee: Deepak Bhole <dbhole>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: ahughes, dbhole, jvanek, omajid
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-14 18:14:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1111827    
Attachments:
Description Flags
Full build.log none

Description Mikolaj Izdebski 2014-07-14 13:28:43 UTC
Description of problem:
There seems to be infinite recursion in the following call:
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4568)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4604)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4785)


Version-Release number of selected component (if applicable):
1.8.0.5-13.b13.fc21.i686

How reproducible:
on Koji on i686. Not reproducible locally on x86_64.

Steps to Reproduce:
koji build --scratch f21 'git://pkgs.fedoraproject.org/jflex?#558dccaeb2000d132b209a27d2b24cea42971ea3'

Actual results:
Build fails with java.lang.StackOverflowError: null
There is infinite recursion in java.util.regex.Pattern

Expected results:
No stach overflow

Comment 1 Mikolaj Izdebski 2014-07-14 13:29:09 UTC
Created attachment 917823 [details]
Full build.log

Comment 2 Deepak Bhole 2014-07-14 18:14:01 UTC
This is not a problem with the JDK.

The pattern that the system ultimately tries to compile/search during the test is in Emitter.java:

  private static final Pattern JAVADOC_COMMENT_AND_MAYBE_ANNOTATIONS_PATTERN
      = Pattern.compile
          (".*/\\*\\*(.*)\\*/"               // javadoc comment, embedded '*/' disallowed
          +"(?:\\s*@[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*)*"        // @[p.ack.age.]AnnotationClass
          +"   (?:\\s*\\(\\s*(?:\"(?:\\\"|[^\"])*\""               // ignore close parens in double quotes
          +"                   |'(?:[^']|\\\\(?:'|u[0-9a-f]{4}))'" // ignore close parens in single quotes
          +"                   |[^)])+\\))?"                       // optional annotation params
          +")*\\s*",                         // zero or more annotations, followed by optional whitespace
           Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.COMMENTS);

That seems like a very complicated pattern that likely needs revision.

The reason why this is happening on only x86 is because on x86, the default stack size is smaller (320k) compared to x86_64 where the stack size is 1024k.

Patterns can always be created such that they will caused a stack overflow. Either the pattern needs to be updated or the stack size needs to be changed.

Running the test with stack size 1024k (-Xss1024k) allows it to pass on i686 where it otherwise fails.

See also: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=5050507

Comment 3 Mikolaj Izdebski 2014-07-14 18:20:00 UTC
Thank you for quick reply.
I will go with increasing stack size for running tests.