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

valgrind: Conditional jump depends on uninitialised value in Arena::set_size_in_bytes()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: hs25
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b08

      Backports

        Description

        The bug is found by running JDK 8 b109 inside valgrind

        The various Arena constructor calls set_size_in_bytes(), like:

        Arena::Arena() {
          _first = _chunk = new (AllocFailStrategy::EXIT_OOM, Chunk::init_size) Chunk(Chunk::init_size);
          _hwm = _chunk->bottom(); // Save the cached hwm, max
          _max = _chunk->top();
          set_size_in_bytes(Chunk::init_size);
          NOT_PRODUCT(Atomic::inc(&_instance_count);)
        }

        void Arena::set_size_in_bytes(size_t size) {
          if (_size_in_bytes != size) {
            _size_in_bytes = size;
            MemTracker::record_arena_size((address)this, size);
          }
        }

        However, at this time, the _size_in_bytes field is not yet initialized, (and it might be equal to size just by chance).

        The fix would be have a different method like

        void Arena::init_size_in_bytes(size_t size) {
          _size_in_bytes = size;
          MemTracker::record_arena_size((address)this, size);
        }

        This should be fixed because it generates a lot of error messages inside valgrind.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  zgu Zhengyu Gu
                  Reporter:
                  iklam Ioi Lam
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: