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

Unsafe load can loose control dependency and cause crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b69

      Backports

        Description

        In this example:

            static void test1(int[] a, boolean[] flags, boolean flag, long j) {
                for (int i = 0; i < 10; i++) {
                    if (flags[i]) {
                        if (flag) {
                            long address = (j << 2) + UNSAFE.ARRAY_INT_BASE_OFFSET;
                            int v = UNSAFE.getInt(a, address);
                            val = v;
                        }
                    }
                }
            }

        the load's control is set to the true branch of if (flag). if (flag) is loop invariant and can be moved out of the loop. Because Node::depends_only_on_test() returns true for loads, the load keeps the true branch of if(flag) as a control and can execute independently of the test if (flags[i]).

        ILW=H(crash) L(never seen) M(disable unsafe intrinsics)=P3

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                roland Roland Westrelin
                Reporter:
                roland Roland Westrelin
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: