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

Loom: Mismatched VirtualThread::state accessor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 19
    • hotspot
    • b26

      Found this by reading the code, no test failure detected yet.

      The field is defined as:

      ```
          // virtual thread state, accessed by VM
          private volatile int state;
      ```

      The field is defined on VM side as:

      ```
        macro(_state_offset, k, "state", int_signature, false)
      ```

      And yet, it is accessed as `short`:

      ```
      u2 java_lang_VirtualThread::state(oop vthread) {
        return vthread->short_field_acquire(_state_offset);
      }
      ```

      I think this is just asking for trouble on different endianness: the partial `u2` read from `int` field can read the "higher" two bytes, not the "lower" two bytes.

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: