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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • hs25
    • hotspot
    • b08

        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.

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

                Created:
                Updated:
                Resolved: