Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 48272 invoked from network); 11 Dec 2007 12:49:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 12:49:37 -0000 Received: (qmail 22856 invoked by uid 500); 11 Dec 2007 12:49:26 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 22836 invoked by uid 500); 11 Dec 2007 12:49:26 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 22827 invoked by uid 99); 11 Dec 2007 12:49:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 04:49:26 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 12:49:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4FC4C1A983A; Tue, 11 Dec 2007 04:49:14 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r603228 - /harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp Date: Tue, 11 Dec 2007 12:49:14 -0000 To: commits@harmony.apache.org From: gshimansky@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071211124914.4FC4C1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gshimansky Date: Tue Dec 11 04:49:13 2007 New Revision: 603228 URL: http://svn.apache.org/viewvc?rev=603228&view=rev Log: Fixed bug HARMONY-5287 [drlvm][jvmti] Lack of synchronization in GetLoadedClasses and GetClassLoaderClasses may cause VM to crash Patch adds synchronization to lock all classloaders until the table of reported classes is filled up. Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp?rev=603228&r1=603227&r2=603228&view=diff ============================================================================== --- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp (original) +++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp Tue Dec 11 04:49:13 2007 @@ -101,6 +101,7 @@ unsigned int cl_count; jvmtiError errorCode; ClassLoader* classloader; + ClassLoader *bootstrap; /* * Check given env & current phase. @@ -114,11 +115,13 @@ return JVMTI_ERROR_NULL_POINTER; } + ClassLoader::LockLoadersTable(); /** * Get the number of loaded classes by bootstrap loader */ - ClassTable* tbl = - VM_Global_State::loader_env->bootstrap_class_loader->GetLoadedClasses(); + bootstrap = VM_Global_State::loader_env->bootstrap_class_loader; + bootstrap->Lock(); + ClassTable* tbl = bootstrap->GetLoadedClasses(); count = tbl->GetItemCount(); /** @@ -128,6 +131,7 @@ for( index = 0; index < cl_count; index++ ) { classloader = (ClassLoader::GetClassLoaderTable())[index]; + classloader->Lock(); tbl = classloader->GetLoadedClasses(); ClassTable::iterator it; for(it = tbl->begin(); it != tbl->end(); it++) @@ -146,6 +150,14 @@ */ if (!count) { + for(index = 0; index < cl_count; index++) + { + classloader = (ClassLoader::GetClassLoaderTable())[index]; + classloader->Unlock(); + } + bootstrap->Unlock(); + ClassLoader::UnlockLoadersTable(); + *classes = NULL; *classes_num = 0; return JVMTI_ERROR_NONE; @@ -156,6 +168,13 @@ */ errorCode = _allocate( (sizeof(jclass) * count), (unsigned char**) classes ); if (errorCode != JVMTI_ERROR_NONE) { + for(index = 0; index < cl_count; index++) + { + classloader = (ClassLoader::GetClassLoaderTable())[index]; + classloader->Unlock(); + } + bootstrap->Unlock(); + ClassLoader::UnlockLoadersTable(); return errorCode; } @@ -187,6 +206,7 @@ (*classes)[number++] = (jclass)new_handle; } + classloader->Unlock(); /** * Get next class loader */ @@ -198,6 +218,7 @@ } while( true ); assert( number == count ); + ClassLoader::UnlockLoadersTable(); /** * Set class number */ @@ -246,11 +267,13 @@ classloader = ClassLoader::FindByObject((((ObjectHandle)initiating_loader)->object)); } + classloader->Lock(); /** * Get the number of loaded classes */ tbl = classloader->GetInitiatedClasses(); if( !(count = tbl->GetItemCount()) ) { + classloader->Unlock(); // no loaded classes *classes_ptr = NULL; *class_count_ptr = 0; @@ -262,6 +285,7 @@ */ errorCode = _allocate( (sizeof(jclass) * count), (unsigned char**)classes_ptr ); if (errorCode != JVMTI_ERROR_NONE) { + classloader->Unlock(); return errorCode; } @@ -281,6 +305,7 @@ } assert( index == count ); + classloader->Unlock(); /** * Set class number */