Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6882582

StackOverflowError in java.util.regex.Pattern

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 6u14, 7
    • core-libs

      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)

            sherman Xueming Shen
            dsimoneksunw David Simonek (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: