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

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

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


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

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

weldon washburn reassigned HARMONY-3203:
----------------------------------------

    Assignee: weldon washburn

> [drlvm]Deadlock in vm_gc_lock_enum()
> ------------------------------------
>
>                 Key: HARMONY-3203
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3203
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Igor V. Stolyarov
>         Assigned To: weldon washburn
>
> 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.


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

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

Gregory Shimansky updated HARMONY-3203:
---------------------------------------

    Patch Info: [Patch Available]

> [drlvm]Deadlock in vm_gc_lock_enum()
> ------------------------------------
>
>                 Key: HARMONY-3203
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3203
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Igor V. Stolyarov
>         Assigned To: weldon washburn
>         Attachments: hythread_global_lock-make-sure-we-are-not-requested-to-suspend.patch
>
>
> 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.


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

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


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

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

Alexey Varlamov updated HARMONY-3203:
-------------------------------------

    Component/s: DRLVM

> [drlvm]Deadlock in vm_gc_lock_enum()
> ------------------------------------
>
>                 Key: HARMONY-3203
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3203
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            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.


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

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

Salikh Zakirov updated HARMONY-3203:
------------------------------------

    Attachment: hythread_global_lock-make-sure-we-are-not-requested-to-suspend.patch

hythread_global_lock-make-sure-we-are-not-requested-to-suspend.patch
fixed hythread_global_lock() to test for a suspend request status, and release global lock before suspending to prevent deadlock

> [drlvm]Deadlock in vm_gc_lock_enum()
> ------------------------------------
>
>                 Key: HARMONY-3203
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3203
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Igor V. Stolyarov
>         Assigned To: weldon washburn
>         Attachments: hythread_global_lock-make-sure-we-are-not-requested-to-suspend.patch
>
>
> 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.


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

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

weldon washburn closed HARMONY-3203.
------------------------------------

    Resolution: Fixed

build, build test works on  windowsxp 32 and rhel 4.0 w/ gcc4.0.2

> [drlvm]Deadlock in vm_gc_lock_enum()
> ------------------------------------
>
>                 Key: HARMONY-3203
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3203
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Igor V. Stolyarov
>         Assigned To: weldon washburn
>         Attachments: hythread_global_lock-make-sure-we-are-not-requested-to-suspend.patch
>
>
> 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.