-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b50
-
os_x, solaris
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8082834 | emb-9 | Nils Eliasson | P4 | Resolved | Fixed | team |
JDK-8330036 | openjdk8u422 | Roman Marchenko | P4 | Resolved | Fixed | b01 |
If you look at the command below, the printed version differs from the command line version at the last 7.
java -XX:CompileCommand=print,\*01234567890123456789012345678901234567890123456789,\*0123456789012345678901234567890123456789 -version
CompilerOracle: print *01234567890123456789012345678901234678901234567789.*0123456789012345678901234678901123456789
Java HotSpot(TM) 64-Bit Server VM warning: printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
The problem is that compilerOracle.cpp uses strcpy to copy within a string and that's specifically described as undefined behaviour for strcpy. Apparently that semantic is somewhat contentious and most strcpy implementations handle the specific case of copying down properly. But not the mac version.
The fix is to use memmove.
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
int match = MethodMatcher::Exact;
while (name[0] == '*') {
match |= MethodMatcher::Suffix;
// Copy remaining string plus NUL to the beginning
memmove(name, name + 1, strlen(name + 1) + 1);
}
java -XX:CompileCommand=print,\*01234567890123456789012345678901234567890123456789,\*0123456789012345678901234567890123456789 -version
CompilerOracle: print *01234567890123456789012345678901234678901234567789.*0123456789012345678901234678901123456789
Java HotSpot(TM) 64-Bit Server VM warning: printing of assembly code is enabled; turning on DebugNonSafepoints to gain additional output
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
The problem is that compilerOracle.cpp uses strcpy to copy within a string and that's specifically described as undefined behaviour for strcpy. Apparently that semantic is somewhat contentious and most strcpy implementations handle the specific case of copying down properly. But not the mac version.
The fix is to use memmove.
static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
int match = MethodMatcher::Exact;
while (name[0] == '*') {
match |= MethodMatcher::Suffix;
// Copy remaining string plus NUL to the beginning
memmove(name, name + 1, strlen(name + 1) + 1);
}
- backported by
-
JDK-8082834 CompilerOracle prefix wildcarding is broken for long strings
- Resolved
-
JDK-8330036 CompilerOracle prefix wildcarding is broken for long strings
- Resolved
- relates to
-
JDK-8252120 compiler/oracle/TestCompileCommand.java misspells "occured"
- Resolved