You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Salikh Zakirov (JIRA)" <ji...@apache.org> on 2007/02/20 11:35:05 UTC

[jira] Commented: (HARMONY-3203) [drlvm]Deadlock in vm_gc_lock_enum()

    [ https://issues.apache.org/jira/browse/HARMONY-3203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474397 ] 

Salikh Zakirov commented on HARMONY-3203:
-----------------------------------------

I have reproduced hang on a first run on Windows/ia32.
The test hang just after message "thread 7996  started".

The problem is in 

void vm_gc_lock_enum()
{
    tmn_suspend_enable();
    hythread_global_lock();
    tmn_suspend_disable();
} // vm_gc_lock_enum


Because there is no guarantee that a thread that just grabbed global thread lock will not be requested for suspension itself.
(It was the case long ago when the only suspend initiator was GC, but now with lock unreservation suspension happens fairly often).

So, the current thread will be suspended on tmn_suspend_disable(), while holding a global thread lock, and the other thread will not be able to resume 
this thread, because it needs to get a global thread lock in order to do it.

The fix will involve careful examination of self->suspend_request to prevent deadlock, and moving suspend_disable_count modifications
into hythread_global_lock() function.

> [drlvm]Deadlock in vm_gc_lock_enum()
> ------------------------------------
>
>                 Key: HARMONY-3203
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3203
>             Project: Harmony
>          Issue Type: Bug
>            Reporter: Igor V. Stolyarov
>
> Application hangs on creation 7997's thread.
> Test for reproduce:
> import java.util.HashMap;
> import java.io.ByteArrayOutputStream;
> import java.io.ObjectOutputStream;
> import java.io.ByteArrayInputStream;
> import java.io.ObjectInputStream;
> public class ObjectStreamClassTest{
>     private static int MAX_THREADS = 10000;
>     private class HashMapSerialize implements Runnable{
>         HashMap map;
>         byte[] form;
>         public HashMapSerialize(HashMap map){ 
>             this.map = map;
>         }
>         public void run(){
>             try{
>                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
>                 ObjectOutputStream oos = new ObjectOutputStream(baos);
>                 oos.writeObject(map);
>                 oos.flush();
>                 form = baos.toByteArray();
>                 oos.close();
>                 baos.close();
>             }catch(Exception e){
>             }
>         }
>     }
>     public ObjectStreamClassTest(){
>     }
>     public void run(){
>         Thread[] t = new Thread[MAX_THREADS];
>         HashMap hm = new HashMap();
>         hm.put("Runnable.class", Runnable.class);
>         try{
>             for(int i = 0; i < MAX_THREADS; i++){
>                 t[i] = new Thread(new HashMapSerialize(hm));
>                 t[i].start();
>                 System.out.println("Thread " + i + ": - started");
>             }
>         }catch(Exception e){
>             System.out.println("Test faild: " + e);
>             return;
>         }
>         System.out.println("Test pass");
>     }
>     public static void main(String[] argv){
>         ObjectStreamClassTest t = new ObjectStreamClassTest();
>         t.run();
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.