Print this page
rev 6886 : 8058251: assert(_count > 0) failed: Negative counter when running runtime/NMT/MallocTrackingVerify.java
Summary: Fixed an issue when overflowing the MallocSite hash table bucket
Reviewed-by: coleenp, gtriantafill

Split Split Close
Expand all
Collapse all
          --- old/hotspot/src/share/vm/runtime/os.cpp
          +++ new/hotspot/src/share/vm/runtime/os.cpp
↓ open down ↓ 563 lines elided ↑ open up ↑
 564  564  }
 565  565  
 566  566  void* os::malloc(size_t size, MEMFLAGS flags) {
 567  567    return os::malloc(size, flags, CALLER_PC);
 568  568  }
 569  569  
 570  570  void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
 571  571    NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
 572  572    NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
 573  573  
 574      -#if INCLUDE_NMT
 575      -  // NMT can not track malloc allocation size > MAX_MALLOC_SIZE, which is
 576      -  // (1GB - 1) on 32-bit system. It is not an issue on 64-bit system, where
 577      -  // MAX_MALLOC_SIZE = ((1 << 62) - 1).
 578      -  // VM code does not have such large malloc allocation. However, it can come
 579      -  // Unsafe call.
 580      -  if (MemTracker::tracking_level() >= NMT_summary && size > MAX_MALLOC_SIZE) {
 581      -    return NULL;
 582      -  }
 583      -#endif
 584      -
 585  574  #ifdef ASSERT
 586  575    // checking for the WatcherThread and crash_protection first
 587  576    // since os::malloc can be called when the libjvm.{dll,so} is
 588  577    // first loaded and we don't have a thread yet.
 589  578    // try to find the thread after we see that the watcher thread
 590  579    // exists and has crash protection.
 591  580    WatcherThread *wt = WatcherThread::watcher_thread();
 592  581    if (wt != NULL && wt->has_crash_protection()) {
 593  582      Thread* thread = ThreadLocalStorage::get_thread_slow();
 594  583      if (thread == wt) {
↓ open down ↓ 50 lines elided ↑ open up ↑
 645  634  
 646  635    // we do not track guard memory
 647  636    return MemTracker::record_malloc((address)ptr, size, memflags, stack, level);
 648  637  }
 649  638  
 650  639  void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) {
 651  640    return os::realloc(memblock, size, flags, CALLER_PC);
 652  641  }
 653  642  
 654  643  void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
 655      -#if INCLUDE_NMT
 656      -  // See comments in os::malloc() above
 657      -  if (MemTracker::tracking_level() >= NMT_summary && size > MAX_MALLOC_SIZE) {
 658      -    return NULL;
 659      -  }
 660      -#endif
 661  644  
 662  645  #ifndef ASSERT
 663  646    NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
 664  647    NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
 665  648     // NMT support
 666  649    void* membase = MemTracker::record_free(memblock);
 667  650    NMT_TrackingLevel level = MemTracker::tracking_level();
 668  651    size_t  nmt_header_size = MemTracker::malloc_header_size(level);
 669  652    void* ptr = ::realloc(membase, size + nmt_header_size);
 670  653    return MemTracker::record_malloc(ptr, size, memflags, stack, level);
↓ open down ↓ 918 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX