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

Turn ON runtime sanitizer in clang toolkit to find issues

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • None
    • infrastructure

      clang sanitizer can identify issues, so we should find a way to run it against our code base. A big issue here is that it requires the target to be actually ran, not just compiled.

      https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
      https://blogs.oracle.com/linux/post/improving-application-security-with-undefinedbehaviorsanitizer-ubsan-and-gcc

      I found a bunch of UB issues by manually turning UndefinedBehaviorSanitizer ON in Xcode project for hotspot (only Mac targeted here, so it would be nice to find a way to run it on other platforms):

      JDK-8300793 UB: Member call on address 0x00011432c7a1 with insufficient space for an object of type 'VMRegImpl'

      JDK-8300795 UB: Load of misaligned address 0x000101015035 for type 'u2' (aka 'unsigned short'), which requires 2 byte alignment

      JDK-8300797 UB: Left shift of negative value -1

      JDK-8300798 UB: Applying non-zero offset 18446744073709551614 to null pointer

      JDK-8300799 UB: Store to misaligned address 0x00012f53408c for type 'uint64_t' (aka 'unsigned long long'), which requires 8 byte
      alignment

      JDK-8300800 UB: Shift exponent 32 is too large for 32-bit type 'int'

      JDK-8300801 UB: Left shift of negative value -14

      JDK-8300802 UB: Left shift of negative value -1

      JDK-8300820 UB: Left shift of negative value -1

      JDK-8300821 UB: Applying non-zero offset to non-null pointer 0xfffffffffffffffe produced null pointer

      JDK-8300822 UB: Load of misaligned address 0x00012f53417c for type 'uint64_t' (aka 'unsigned long long'), which requires 8 byte
      alignment

      JDK-8300823 UB: Load of value 32, which is not a valid value for type 'bool'

      JDK-8300824 UB: Member access within misaligned address 0x000101015865 for type 'const Classfile_LVT_Element', which requires 2
      byte alignment

      JDK-8300825 UB: Signed integer overflow: 9223372036854775807 + 3 cannot be represented in type 'long'

      JDK-8300826 UB: Left shift of negative value -1145132374

      JDK-8300827 UB: Upcast of misaligned address 0x0000deadbeef for type 'PhaseChaitin', which requires 8 byte alignment

      It would be nice if this was done for all sanitizer checks and have them reported automatically.

            Unassigned Unassigned
            gziemski Gerard Ziemski
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: