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

Probable String::indexOf intrinsic bug with chars above 0xff

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 24.0.2
    • hotspot
    • x86_64
    • windows

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11 (can't select above)
      Affects OpenJDK 24 and 25

      A DESCRIPTION OF THE PROBLEM :
      I believe it's caused by this change:
      JDK-8320448
      I found a bug issue:
      JDK-8360271

      I'd like to add a simple Java reproducer for the problem.
      My workaround is to disable 'EnableX86ECoreOpts'

      REGRESSION : Last worked in version 23

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please run the JUnit test below

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      As the test expects: 9
      ACTUAL -
      Actual is -1 if the intrinsic was used (I assume)

      ---------- BEGIN SOURCE ----------
      public class ReproStringBugTest {

          @BeforeClass // if this line is commented out, the tests are good
          public static void warmup() {
              for (int i = 0; i < 10_000; i++) { // could also just specify -Xcomp VM option but thats much much slower
                  "Sher\ufffflockSherlock".indexOf("Sherlock");
                  "Sher\ufffflockSherlock".indexOf("Sherlock", 0);
              }
          }

          @Test
          public void repro1() {
              // any char above 0xff seems to trigger this error
              Assert.assertEquals(9, "Sher\ufffflockSherlock".indexOf("Sherlock"));
          }

          @Test
          public void repro2() {
              Assert.assertEquals(9, "Sher\ufffflockSherlock".indexOf("Sherlock", 0));
          }
      }

      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: