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

CompilerOracle prefix wildcarding is broken for long strings

XMLWordPrintable

    • b50
    • os_x, solaris

        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);
          }

              neliasso Nils Eliasson (Inactive)
              never Tom Rodriguez
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: