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

CodeSection::alignment checks for CodeBuffer::SECT_STUBS incorrectly

    XMLWordPrintable

Details

    • b21

    Description

      Code added in CodeSection::alignment by JDK-8287373 triggers -Wint-in-bool-context warning on GCC (currently globally ignored), due to apparent bug.

      Patching current code with:

      ```
      diff --git a/src/hotspot/share/asm/codeBuffer.hpp b/src/hotspot/share/asm/codeBuffer.hpp
      index 96af0eebbdc..79b383e7287 100644
      --- a/src/hotspot/share/asm/codeBuffer.hpp
      +++ b/src/hotspot/share/asm/codeBuffer.hpp
      @@ -752,11 +752,11 @@ inline int CodeSection::alignment(int section) {
         if (section == CodeBuffer::SECT_INSTS) {
           return (int) CodeEntryAlignment;
         }
      - if (CodeBuffer::SECT_STUBS) {
      + if (section == CodeBuffer::SECT_STUBS) {
           // CodeBuffer installer expects sections to be HeapWordSize aligned
           return HeapWordSize;
         }
      - ShouldNotReachHere();
      + fatal("What: %d", section);
         return 0;
       }
      ```

      Yields the failure right at build time:

      ```
      # Internal Error (/home/shade/trunks/jdk/src/hotspot/share/asm/codeBuffer.hpp:759), pid=1422115, tid=1422120
      # fatal error: What: -1

      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.so+0x8aae01] CodeSection::alignment(int)+0x45 (codeBuffer.hpp:759)
      V [libjvm.so+0x8aab52] CodeSection::alignment()+0x22 (codeBuffer.hpp:260)
      V [libjvm.so+0x8a54ff] CodeBuffer::initialize(int, int)+0x2f (codeBuffer.cpp:103)
      V [libjvm.so+0x8aacf5] CodeBuffer::CodeBuffer(char const*, int, int)+0xcb (codeBuffer.hpp:539)
      V [libjvm.so+0x1396a28] StubGenerator::generate_throw_exception(char const*, unsigned char*, Register, Register)+0x68 (stubGenerator_x86_64.cpp:3540)
      V [libjvm.so+0x13970e9] StubGenerator::generate_initial()+0x1d5 (stubGenerator_x86_64.cpp:3653)
      V [libjvm.so+0x1398707] StubGenerator::StubGenerator(CodeBuffer*, int)+0x57 (stubGenerator_x86_64.hpp:523)
      V [libjvm.so+0x1398367] StubGenerator_generate(CodeBuffer*, int)+0x42 (stubGenerator_x86_64.cpp:3918)
      V [libjvm.so+0x13e6e3d] StubRoutines::initialize1()+0x113 (stubRoutines.cpp:228)
      V [libjvm.so+0x13e7d8d] stubRoutines_init1()+0xd (stubRoutines.cpp:389)
      V [libjvm.so+0xc6c782] init_globals()+0x34 (init.cpp:123)
      V [libjvm.so+0x1485e0b] Threads::create_vm(JavaVMInitArgs*, bool*)+0x3f3 (threads.cpp:570)
      V [libjvm.so+0xd8b591] JNI_CreateJavaVM_inner(JavaVM_**, void**, void*)+0xed (jni.cpp:3628)
      V [libjvm.so+0xd8b8da] JNI_CreateJavaVM+0x36 (jni.cpp:3714)
      C [libjli.so+0x891f] InitializeJVM+0x150 (java.c:1457)
      C [libjli.so+0x560c] JavaMain+0xe0 (java.c:413)
      C [libjli.so+0xc4a5] ThreadJavaMain+0x2b (java_md.c:650)
      ```

      ...as this code touches the `alignment()` before relevant sections are initialized:

      ```
      void CodeBuffer::initialize(csize_t code_size, csize_t locs_size) {
        ...
        assert(SECT_LIMIT == 3, "total_size explicitly lists all section alignments");
        int total_size = code_size + _consts.alignment() + _insts.alignment() + _stubs.alignment() + SECT_LIMIT * slop;
        ...
        // Set up various pointers into the blob.
        initialize(_total_start, _total_size); // <---- actually initialized here
      ```

      Attachments

        Issue Links

          Activity

            People

              bulasevich Boris Ulasevich
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: