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

offset_of for GCC/Clang exhibits undefined behavior and is not always a compile-time constant

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      UBSan was triggered by the offset_of implementation for GCC/Clang defined in utilities/globalDefinitions_gcc.hpp. It only aligns the temporary buffer it uses to 16 bytes, while some structs/class require greater alignment, such as zCollectedHeap. UBSan stack trace also suggested that offset_of is not a compile-time constant as the stack trace showed that it was being called during library loading.

      The comment in utilities/globalDefinitions_gcc.hpp says the offset_of was rolled to avoid a warning. I suggest we simply ignore the warning globally in the build system (pragma pushing doesn't work with precompiled headers) and just use offsetof.

            jcking Justin King
            jcking Justin King
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: