Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 46008 invoked from network); 13 Jun 2007 10:15:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jun 2007 10:15:47 -0000 Received: (qmail 26735 invoked by uid 500); 13 Jun 2007 10:15:51 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 26706 invoked by uid 500); 13 Jun 2007 10:15:50 -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 26696 invoked by uid 99); 13 Jun 2007 10:15:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2007 03:15:50 -0700 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.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2007 03:15:46 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 45F037141E5 for ; Wed, 13 Jun 2007 03:15:26 -0700 (PDT) Message-ID: <20577217.1181729726283.JavaMail.jira@brutus> Date: Wed, 13 Jun 2007 03:15:26 -0700 (PDT) From: "Gregory Shimansky (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-3866) [drlvm][jvmti] GetOwnedMonitorInfo returns information about 1 monitor even if there are no monitors owned by the specified thread In-Reply-To: <30288057.1179211096388.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12504187 ] Gregory Shimansky commented on HARMONY-3866: -------------------------------------------- The bug is indeed in JVMTI implementation. Adding can_get_owned_monitor_info capability didn't switch the TI mode of thread manager, so it sometimes used fast path for monitors, and therefore these monitors were not seen by TI. One line patch should fix the bug as makes the test to pass. Will commit after testing. > [drlvm][jvmti] GetOwnedMonitorInfo returns information about 1 monitor even if there are no monitors owned by the specified thread > ---------------------------------------------------------------------------------------------------------------------------------- > > Key: HARMONY-3866 > URL: https://issues.apache.org/jira/browse/HARMONY-3866 > Project: Harmony > Issue Type: Bug > Components: DRLVM > Environment: Windows and Linux > Reporter: Vera Petrashkova > Assignee: Gregory Shimansky > Priority: Minor > Attachments: GOMI.zip > > > According to J2SE JVMTI specification method > GetOwnedMonitorInfo jvmtiEnv* env, > jthread thread, > jint* owned_monitor_count_ptr, > jobject** owned_monitors_ptr) > returns information about the monitors owned by the specified thread. > It saves the number of monitors to owned_monitor_count_ptr. > The following test demonstrates that on DRLVM returns information about 1 monitor even if there are no monitors owned by the specified thread. > In this case on RI returned value of owned_monitor_count_ptr parameter equals 0. > --------------------GOMI.java------------------- > public class GOMI { > public static boolean all_threads_can_start = false; > public final static Object sync0 = new Object(); > public final static Object sync1 = new Object(); > > public static void main(String[] args) { > GOMI_thread tr = new GOMI_thread("Owner"); > tr.start(); > } > } > class GOMI_ag extends Thread { > public GOMI_ag(String s) { > super(s); > } > public void run() { > return; > } > } > class GOMI_thread extends Thread { > GOMI_thread(String name) { > super(name); > } > public void run() { > try { > Thread.sleep(5000); > } catch (Throwable e) { > e.printStackTrace(); > } > try { > GOMI_ag ag = new GOMI_ag("agent"); > ag.start(); > ag.join(); > } catch (Throwable te) { > te.printStackTrace(); > } > try { > Thread.sleep(5000); > } catch (Throwable e) { > e.printStackTrace(); > } > } > } > ----------------GOMI.cpp------------------------ > #include "evnts.h" > static bool flag = false; > static bool flag_res = false; > void GOMI() > { > } > JNIEXPORT jint JNICALL Agent_OnLoad(prms_AGENT_ONLOAD) > { > Callbacks CB; > CB.cbThreadStart = (jvmtiEventThreadStart)callbackThreadStart; > CB.cbVMDeath = (jvmtiEventVMDeath)callbackVMDeath; > AGENT_FOR_EVENTS_TESTS_PART_I; /* evnts.h */ > jvmtiEvent events[] = { JVMTI_EVENT_THREAD_START, JVMTI_EVENT_VM_DEATH }; > AGENT_FOR_EVENTS_TESTS_PART_II; /* evnts.h */ > fprintf(stderr, "\n-----------test GOMI started--------------\n"); > fflush(stderr); > return JNI_OK; > } > /* *********************************************************************** */ > void JNICALL callbackThreadStart(prms_THRD_START) > { > if (flag) return; > jvmtiPhase phase; > jvmtiThreadInfo tinfo; > jvmtiError result; > jint tcount = 0; > jthread* threads; > jthread my_thread = NULL; > jint owned_monitor_count; > jobject* owned_monitors; > result = jvmti_env->GetPhase(&phase); > if ((result != JVMTI_ERROR_NONE) || (phase != JVMTI_PHASE_LIVE)) return; > result = jvmti_env->GetThreadInfo(thread, &tinfo); > if (result != JVMTI_ERROR_NONE) return; > fprintf(stderr, "\tnative: current started thread name is %s \n", tinfo.name); > if (strcmp(tinfo.name, "agent")) return; > fprintf(stderr, "\tnative: test started\n"); > result = jvmti_env->GetAllThreads(&tcount, &threads); > if (result != JVMTI_ERROR_NONE) return; > for ( int i = 0; i < tcount; i++ ) { > result = jvmti_env->GetThreadInfo(threads[i], &tinfo); > fprintf(stderr, "\tnative: current thread %d name is %s \n", i, tinfo.name); > if (result != JVMTI_ERROR_NONE) continue; > if (strcmp(tinfo.name, "Owner")) continue; > my_thread = threads[i]; > fprintf(stderr, "\tnative: tested thread was found = %p %s %d\n", my_thread, tinfo.name, i); > } > result = jvmti_env->GetOwnedMonitorInfo(my_thread, > &owned_monitor_count, &owned_monitors); > flag = true; > fprintf(stderr, "\tnative: GetOwnedMonitorInfo result = %d (must be zero) \n", result); > fprintf(stderr, "\n\tnative: number of owned monitors is %d (must be 0)\n", > owned_monitor_count ); > if ((result == JVMTI_ERROR_NONE) && (owned_monitor_count == 0)) { > flag_res = true; > return; > } > } > void JNICALL callbackVMDeath(prms_VMDEATH) > { > fprintf(stderr, "\n\tTest GOMI: "); > if (flag && flag_res) > fprintf(stderr, " passed \n"); > else > fprintf(stderr, " failed \n"); > fprintf(stderr, "\n} /* test GOMI finished */ \n"); > fflush(stderr); > } > ------------------------------------------------ > Attachment contains additional source code files and GOMI.dll > Output on DRLVM: > ================ > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l > icensors, as applicable. > java version "1.5.0" > pre-alpha : not complete or compatible > svn = r537729, (May 14 2007), Windows/ia32/msvc 1310, release build > http://incubator.apache.org/harmony > -----------test GOMI started-------------- > native: current started thread name is main > native: current started thread name is Owner > native: current started thread name is agent > native: test started > native: current thread 0 name is agent > native: current thread 1 name is Owner > native: tested thread was found = 0218FFFC Owner 1 > native: current thread 2 name is ref handler > native: current thread 3 name is finalizer > native: current thread 4 name is finalizer > native: current thread 5 name is main > native: GetOwnedMonitorInfo result = 0 (must be zero) > native: number of owned monitors is 1 (must be 0) > Test GOMI: failed > } /* test GOMI is finished */ > Output on RI: > =========== > -----------test GOMI started-------------- > native: current started thread name is Signal Dispatcher > native: current started thread name is main > java version "1.5.0_06" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) > Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode) > native: current started thread name is Owner > native: current started thread name is DestroyJavaVM > native: current started thread name is agent > native: test started > native: current thread 0 name is agent > native: current thread 1 name is DestroyJavaVM > native: current thread 2 name is Owner > native: tested thread was found = 00A877F4 Owner 2 > native: current thread 3 name is Signal Dispatcher > native: current thread 4 name is Finalizer > native: current thread 5 name is Reference Handler > native: GetOwnedMonitorInfo result = 0 (must be zero) > native: number of owned monitors is 0 (must be 0) > Test GOMI: passed > } /* test GOMI is finished */ > This bug causes the failure of the test > vm.jvmti.funcs.GetOwnedMonitorInfo.GetOwnedMonitorInfo0101.GetOwnedMonitorInfo0101 > from DRLVM Validation test suite (http://issues.apache.org/jira/browse/HARMONY-3206) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.