You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Gregory Shimansky (JIRA)" <ji...@apache.org> on 2007/06/13 14:44:26 UTC

[jira] Resolved: (HARMONY-3866) [drlvm][jvmti] GetOwnedMonitorInfo returns information about 1 monitor even if there are no monitors owned by the specified thread

     [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky resolved HARMONY-3866.
----------------------------------------

    Resolution: Fixed

Patch is applied at 546843. The test org.apache.harmony.jpda.tests.jdwp.ThreadReference.OwnedMonitorsTest passes for me now.

> [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.