JDK-6882582 : StackOverflowError in java.util.regex.Pattern
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.regex
  • Affected Version: 6u14,7
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2009-09-16
  • Updated: 2018-09-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description
On specific input and rather complex pattern, java.util.regex Matcher gets confused during Matcher.match() call and finishes with StackOverflowError (see below).

I'm attaching small test java app which demonstrates the problem. Test app reads java source file and tries to detect java package name using reg exp. Test tries two resource files with nearly the same content, but Matcher survives only one of them, please see test source for details.

1) Attachment Main.java contains source of test app
2) Attachment MatcherStackOverflow contains zipped netbeans project with complete sources and compiled jar in /dist subdir.

Exception in thread "main" java.lang.StackOverflowError
	at java.util.regex.Pattern$Branch.match(Pattern.java:4110)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
	at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3366)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4114)