United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7125594 C-heap growth issue in ThreadService::find_deadlocks_at_safepoint
JDK-7125594 : C-heap growth issue in ThreadService::find_deadlocks_at_safepoint

Details
Type:
Bug
Submit Date:
2011-12-28
Status:
Closed
Updated Date:
2013-04-20
Project Name:
JDK
Resolved Date:
2012-03-29
Component:
hotspot
OS:
generic
Sub-Component:
svc
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs23 (b10)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
In the process of debugging 7066129  the customer found another user who is also seeing C-heap growth. 

They have narrowed it down to ThreadService::find_deadlocks_at_safepoint
 
  
> gdb) info leak 4
> 240 bytes leaked in 10 blocks (0.68% of all bytes leaked)
> These range in size from 24 to 24 bytes and are allocated
> #0  0x9fffffff7e944fa2 in os::malloc(unsigned long)   at
> /wsp/jinteg/SVN/jinteg_h6.0.13.rc1b1/hotspot/src/share/vm/runtime/os.cpp:793
> #1  0x9fffffff7cff5a22 in CHeapObj::operator new(unsigned long)   at
> /wsp/jinteg/SVN/jinteg_h6.0.13.rc1b1/hotspot/src/share/vm/memory/allo
> cation.cpp:50
> #2  0x9fffffff7ed95a
> <http://ukpatch.uksr.hp.com:32080/search/patch?patch=ff7ed95a>32 in
> ThreadService::find_deadlocks_at_safepoint(bool)   at
> /wsp/jinteg/SVN/jinteg_h6.0.13.rc1b1/hotspot/src/share/vm/
> services/threadService.cpp:306
> #3  0x9fffffff7ee7f822 in VM_FindDeadlocks::doit()
See comments for the testcase.

                                    

Comments
PUBLIC COMMENTS

Testcase:

import java.lang.management.*;
import java.io.*;
import java.lang.*;
import java.util.*;
 
class TESTleak {
 
static void checkit(){
try {
while (1 ==1 ){
ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
  long[] ids = tmx.findDeadlockedThreads();
  if (ids != null) {
     System.out.println("The following threads are deadlocked:");
  }
Thread.sleep(1000);
}
} catch (Exception e) {
System.out.println("Got Exception..");
}
}
 
public static void main( String Args[]){
checkit();
}
}
                                     
2011-12-29
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/8a63c6323842
                                     
2012-01-05
SUGGESTED FIX

The ThreadService::find_deadlocks_at_safepoint method
leaks on DeadlockCycle object every time it is called.

A DeadlockCycle object, referenced by the 'cycle' local
variable, is pre-allocated and used to store blocked
threads. If a deadlock is found, 'cycle' is added to the
deadlock list (referenced by the 'deadlocks' local
variable) and a new DeadlockCycle object is created and
re-assign to the 'cycle' variable.

Once all the threads have been processed, the deadlock
list is returned, or NULL if no deadlock has been
found. In both case, the last DeadlockCycle object
that has been allocated, still referenced by 'cycle',
is not returned to caller method nor deallocated,
causing the memory leak.

The fix is to call delete on the object pointed by
'cycle' before returning the result.
                                     
2012-01-06
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/8a63c6323842
                                     
2012-01-07
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/8a63c6323842
                                     
2012-03-22



Hardware and Software, Engineered to Work Together