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

Undefined behavior in C1 LIR_OprDesc causes SEGV in fastdebug build

    XMLWordPrintable

Details

    • b24

    Description

      Building HotSpot with LLVM 13 fails due to SEGV at FrameMap::java_calling_convention(GrowableArray<BasicType> const*, bool). See attached log.

      The root cause is the following code in LIR_OprDesc:
        // Conversion
        intptr_t value() const { return (intptr_t) this; }

      This pattern is a source of undefined behavior in C++. This is similar to the issue with markOop/markOopDesc that was fixed in JDK-8229258.

      In this case, the undefined behavior happens with:
        bool check_value_mask(intptr_t mask, intptr_t masked_value) const {
          return (value() & mask) == masked_value;
        }
      Compiler can make various optimizations if it believes "this" pointer is aligned. The LLVM optimization that tripped this is https://reviews.llvm.org/rG16d03818412415c56efcd482d18c0cbdf712524c , which is a roll-forward of https://reviews.llvm.org/D99790.

      Properly fixing this requires wide refactoring of the use cases of LIR_OprDesc.

      Colleagues James Y Knight and [~rasbold] have contributed a workaround patch with some hacks to reduce the patch size. I will publish this partial fix to collect initial feedback, and see if we could proceed with the patch, or if there are volunteers to pick up this work.

      Attachments

        Issue Links

          Activity

            People

              manc Man Cao
              manc Man Cao
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: