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

Bitwise AND on byte value sometimes produces wrong result

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1 P1
    • 11
    • 11
    • hotspot
    • b18
    • x86_64
    • os_x

        We are seeing a number of test failures when running Nashorn test262 tests with JDK 11. The failures only happen when running a large chunk of the test suite, not when running just the failing tests alone.

        The failures are caused by the Nashorn encodeURI function returning the wrong result. Specifically, the following condition at line 274 in src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/URIUtils.java sometimes evaluates to true when it should evaluate to false:

                    if ((b[i] & 0xff) < 0x10) {

        b being of type byte[] and b[i] being a negative byte value.
        If I change above condition to the one below the failures disappear.

                    if ((b[i] & 0xff) < 0x10 && b[i] >= 0) {

        Steps to reproduce:

        cd make/nashorn
        ant externals
        ant test262parallel -Dtest262-test-sys-prop.test.js.roots=test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/

        The last step runs a large enough subset to reproduce the problem. It should terminate without failures, but currently produces 11 failures:

             [java] FAILED TESTS
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.3/S15.1.3.3_A2.3_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #3629-D7FF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.3/S15.1.3.3_A2.4_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #D800-DBFF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.3/S15.1.3.3_A2.4_T2.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #DC00-DFFF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.3/S15.1.3.3_A2.5_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #E000-FFFF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.3/S15.1.3.3_A4_T2.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #1: http://ru.wikipedia.org/wiki/Юникод
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.4/S15.1.3.4_A2.2_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #0080-07FF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.4/S15.1.3.4_A2.3_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #0800-D7FF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.4/S15.1.3.4_A2.4_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #D800-DBFF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.4/S15.1.3.4_A2.4_T2.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #DC00-DFFF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.4/S15.1.3.4_A2.5_T1.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #E000-FFFF
             [java] Test(compile, run): test/nashorn/script/external/test262/test/suite/ch15/15.1/15.1.3/15.1.3.4/S15.1.3.4_A4_T2.js
             [java] test/nashorn/script/external/test262/test/harness/sta.js:286:4 Error: #1: http://ru.wikipedia.org/wiki/Юникод
             [java] Tests run: 160/160 tests, passed: 149 (93.13%), failed: 11. Time elapsed: 1min 35s.

              shade Aleksey Shipilev
              hannesw Hannes Wallnoefer
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: