You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vera Petrashkova (JIRA)" <ji...@apache.org> on 2007/05/15 08:38:16 UTC

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

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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky closed HARMONY-3866.
--------------------------------------


VERIFIED

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


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

Posted by "Ivan Popov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503041 ] 

Ivan Popov commented on HARMONY-3866:
-------------------------------------

GetOwnedMonitorInfo() still reports not all owned monitors for a thread. This causes JDWP test mentioned above (org.apache.harmony.jpda.tests.jdwp.ThreadReference.OwnedMonitorsTest) to fail with the following diagnostics:

==> testedThreadID = 1868
==> suspend testedThread...
owned monitors: 0
# ERROR: wrong number of owned monitors: 0 (expected at least 2)

Also, Eclipse debugger shows wrong monitors for a thread when this option is turned on, this causes failures of corresponding Eclipse debug scenarios.


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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503033 ] 

Gregory Shimansky commented on HARMONY-3866:
--------------------------------------------

I can also explain why in this test sometimes the number of owned monitors is 2 (I cannot explain how it can report 0 monitors though). The method Thread.start actually acquires 2 monitors, 1st one is "this" (the thread object) because method start is synchronized, as I've written previously, the 2nd one is "lock" which is used for managing thread java state.

But later thread that started a thread performs lock.wait(), which exits the monitor for the time while this thread is waiting. So if the ThreadStart event for the newly started thread happens while starter thread is not waiting on lock.wait, then the number of owned monitors should be 2, otherwise when starter thread is executing wait, the number of owned monitors should be 1.

Removing synchronized keyword on Thread.start method won't solve the race condition in the test. Its results still won't be consistent because the number of reported monitors will be either 0 or 1.

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


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

Posted by "Vera Petrashkova (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vera Petrashkova updated HARMONY-3866:
--------------------------------------

    Attachment: GOMI.zip

Test source code, class files and library.

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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503030 ] 

Gregory Shimansky commented on HARMONY-3866:
--------------------------------------------

BTW it seems to be that method start may be made unsynchronized because everywhere in Thread.java I see that synchronization of thread states is made under synchronized(lock) statement. So synchronizing on the thread object itself doesn't make much sense to me...

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


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

Posted by "Ivan Popov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500180 ] 

Ivan Popov commented on HARMONY-3866:
-------------------------------------

The following JPDA unit test form jdktools component fails because of incorrect data returned by GetOwnedMonitorInfo().

    org.apache.harmony.jpda.tests.jdwp.ThreadReference.OwnedMonitorsTest

The test fails intermittently, because GetOwnedMonitorInfo() returns different number of owned monitors, even 0 sometimes.. With patch for HARMONY-4002 this test fails stably.


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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@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.


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503069 ] 

Gregory Shimansky commented on HARMONY-3866:
--------------------------------------------

I can reproduce the failure of org.apache.harmony.jpda.tests.jdwp.ThreadReference.OwnedMonitorsTest test. I wonder what is the target thread for the GetOwnedMonitorsInfo function? Is the the thread OwnedMonitorsDebuggee.run or is it DebuggeeThread.run?

I am also curious about the

synchronized (lock) {
    lock.wait();
}

behavior. Does RI report "lock" object monitor when lock.wait is executing? In DRLVM the lock monitor is explicitly removed from the array of thread owned monitors. Maybe it is a wrong thing to do?...

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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503110 ] 

Gregory Shimansky commented on HARMONY-3866:
--------------------------------------------

I figured as much about the target thread in the test. The thread should have 2 locked monitors and I am investigating why it doesn't.

It doesn't really execute wait on the acquires monitors of synchronization, it was a separate question because I didn't find any mentioning of it in the spec.

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


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

Posted by "Ivan Popov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12504585 ] 

Ivan Popov commented on HARMONY-3866:
-------------------------------------

Verified in harmony-jdk-r547139, now both JDWP tests and Eclipse debugger works fine. This can be closed.


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


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

Posted by "Ivan Popov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503104 ] 

Ivan Popov commented on HARMONY-3866:
-------------------------------------

The test checks number of owned monitors for DebuggeeThread when it is in run() method:

        public void run() {
            synchronized(OwnedMonitorsDebuggee.waitForFinish){
                synchronized(OwnedMonitorsDebuggee.waitForStart){

                    OwnedMonitorsDebuggee.waitForStart.notifyAll();

                    logWriter.println(getName() +  ": started");
                    synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);

                    logWriter.println(getName() +  ": wait for SGNL_CONTINUE");
                    synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); // <-- suspended here
                    logWriter.println(getName() +  ": finished");
                }
            }
        }

At this time the thread owns at least two monitors - waitForFinish and waitForStart.

Please note, this code does not use wait(). I think after monitor is implicitly released in wait() then it is not owned by a thread until is reacquired again.


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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ 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.


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503029 ] 

Gregory Shimansky commented on HARMONY-3866:
--------------------------------------------

JVMTI implementation is correctly working for this test.

The test tries to get monitors for the thread of class GOMI_thread at the point when it starts thread GOMI_ag (line 38 in GOMI.java). The method j.l.Thread.start in DRLVM is synchronized, so the thread acquires the monitor on object GOMI_ag. That is why JVMTI always reports a single acquired monitor at this point.

I suggest to close this bug as invalid because the test is either wrong or uses incorrect assumptions.


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


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

Posted by "Gregory Shimansky (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gregory Shimansky reassigned HARMONY-3866:
------------------------------------------

    Assignee: Gregory Shimansky

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