United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6496392 attach_current_thread can leak JavaThread object (and associated data structures) if an error occurs
JDK-6496392 : attach_current_thread can leak JavaThread object (and associated data structures) if an error occurs

Details
Type:
Bug
Submit Date:
2006-11-22
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2007-06-20
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs10 (b14)

Related Reports
Backport:
Backport:

Sub Tasks

Description
In attach_current_thread we reach a point where we "new" a JavaThread object for the current thread. After that there are two places where we return JNI_ERR, the first of which does not clean up the JavaThread that was created.
Similarly create_vm can also leak the JavaThread and associated structures.

                                    

Comments
SUGGESTED FIX

*** /tmp/geta12122	Wed Nov 22 16:16:36 2006
--- jni.cpp	Wed Nov 22 16:16:29 2006
***************
*** 3335,3342 ****
    thread->record_stack_base_and_size();
    thread->initialize_thread_local_storage();
  
!   if (!os::create_attached_thread(thread))
!      return JNI_ERR;
  
    // Crucial that we do not have a safepoint check for this thread, since it has
    // not been added to the Thread list yet.
--- 3335,3344 ----
    thread->record_stack_base_and_size();
    thread->initialize_thread_local_storage();
  
!   if (!os::create_attached_thread(thread)) {
!     delete thread;
!     return JNI_ERR;
!   }
                                     
2006-11-22
EVALUATION

Submitter is correct.
                                     
2006-11-22



Hardware and Software, Engineered to Work Together