-
Bug
-
Resolution: Fixed
-
P5
-
5.0
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Slackware 10.1.0, SuSE Linux 9.1 (i586)
A DESCRIPTION OF THE PROBLEM :
Combining capturing groups with greedy quantifiers in variety of cases can cause JVM to halt further execution once it reaches Matcher.matches() method.
CPU utilization jumps to 100%, load grows, etc... No exception or JVM error message is being thrown. Solution is to kill the process.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code. -:) It is the simplest always reproducable case I've found.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
public class Test {
public static void main(String[] args) {
String text = "aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbb";
System.out.println(text);
Pattern p = Pattern.compile("(.*){2,}x");
Matcher m = p.matcher(text);
if (m.find()) {
int start = m.start();
int end = m.end();
String matched = text.substring(start, end);
System.out.println(matched);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
typically possible by not using capturing groups in the same regexp. E.g. \\w{2,} instead of (.*){2,} where applicable.
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Slackware 10.1.0, SuSE Linux 9.1 (i586)
A DESCRIPTION OF THE PROBLEM :
Combining capturing groups with greedy quantifiers in variety of cases can cause JVM to halt further execution once it reaches Matcher.matches() method.
CPU utilization jumps to 100%, load grows, etc... No exception or JVM error message is being thrown. Solution is to kill the process.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code. -:) It is the simplest always reproducable case I've found.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
public class Test {
public static void main(String[] args) {
String text = "aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbb";
System.out.println(text);
Pattern p = Pattern.compile("(.*){2,}x");
Matcher m = p.matcher(text);
if (m.find()) {
int start = m.start();
int end = m.end();
String matched = text.substring(start, end);
System.out.println(matched);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
typically possible by not using capturing groups in the same regexp. E.g. \\w{2,} instead of (.*){2,} where applicable.