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

MetaspaceShared base calculation may cause overflow in align_up

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • None
    • hotspot
    • b08

      As discussed in the review of JDK-8318127, align_up has an (implicit) post-condition that value-to-align <= result. The change that was made was to assert that said post-condition can be achieved by checking the arguments. It didn't do a post-operation check because some cases where that can't be achieved might invoke UB in the operation.

      The problem that was encountered was that the MetaspaceShared base calculation (see compute_shared_base) uses align_up in a manner that can overflow, and then attempts to check for that overflow. But an overflow will trip the assertion that was added to align_up. The base calculation needs to be revised to not do that.

      https://github.com/openjdk/jdk/blob/15378a785356bdf574e557633d36591f5cfc1610/src/hotspot/share/cds/metaspaceShared.cpp#L215-L242

            ccheung Calvin Cheung
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: