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

Bad alignment check in MemorySegment.elements

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 20
    • 19, 20, repo-panama
    • core-libs
    • None

    Description

      The change in this commit:

      https://github.com/openjdk/jdk/commit/9d43d25da8bcfff425a795dcc230914a384a5c82#diff-a311ae3c57c4204970424f03af3d0744a80f9ce43c2e4f6fdad8dc83bbfe515d

      Introduced a regression in few routines such as MemorySegment.elements which want to ensure that the size of the segments has to be a multiple of the layout.

      The check went from:

      byteSize() % elementLayout.byteSize() != 0

      To:

      (byteSize() & (elementLayout.byteSize() - 1)) == 0;

      The latter check only works for power of two (in fact we use it for alignment checks), so this change is incorrect.

      Attachments

        Activity

          People

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: