harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "weldon washburn (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3864) [drlvm][thread] VM sometimes hangs after ThreadGroup.setMaxPriority()
Date Thu, 21 Jun 2007 19:05:26 GMT

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

weldon washburn commented on HARMONY-3864:
------------------------------------------

I looked at the patch.  It seems to make sense.  I have no problem committing this patch if
it fixes the setMaxPriority problem and does not create more bugs.

Some questions

1)
Ilya mentions "it wraps into global TM lock j.l.Thread.detach()" in the above description.
 In specific do you mean you somehow tried to use java.lang.Thread.lock which is defined as
"Object lock = new Object();" or some other synch primitive?

2)
Can you tell us about the other Java locks approaches that were tried and leads to deadlock?

3)
It seems this patch also fixes several other very similar race conditions.  For example, a
conflict between group.remove(this) and nonSecureInterrupt().  Are there any additional stress
tests that now pass once this patch is applied?  Is this analysis correct?

> [drlvm][thread] VM sometimes hangs after ThreadGroup.setMaxPriority()
> ---------------------------------------------------------------------
>
>                 Key: HARMONY-3864
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3864
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Windows and Linux
>            Reporter: Vera Petrashkova
>            Assignee: weldon washburn
>            Priority: Minor
>         Attachments: global_lock.patch, H3864.patch, ThreadGroupTest.java
>
>
> The following test demonstrates that sometimes VM hangs on some thread after invocation
of 
> the  method ThreadGroup.setMaxPriority(int) 
> ------------------ThreadGroupTest.java-----------------
> import java.io.*;
> public class ThreadGroupTest {
>     public static int nmbTG = 20;
>     public static int nmbTH = 20;
>     public static boolean isDaemon = false;
>     public static boolean setPrior = false;
>     public static void main(String[] args) {
>         if ((args.length >= 1) && "true".equals(args[0])) {
>             isDaemon = true;
>         }
>         if ((args.length >= 2) && "true".equals(args[1])) {
>             setPrior = true;
>         }
>         for (int t = 0; t < 100; t++) {
>             new ThreadGroupTest().test();
>             System.err.println("Step: "+t+"  finished");
>         }
>         System.err.println("Test passed");
>     }
>     public void test() {
>         ThreadGroup roottg = new ThreadGroup("root-tg");
>         roottg.setDaemon(isDaemon);
>         Thread_t [] threads1 = new Thread_t[nmbTH];
> 	for (int i = 0; i < nmbTH; i ++) {
>             threads1[i] = new Thread_t(roottg,"roottg");
>         }
>         ThreadGroup [] tg = new ThreadGroup[nmbTG];
>         Thread_t [][] threads = new Thread_t[nmbTG][nmbTH];
> 	for (int i = 0; i < nmbTG; i ++) {
>             tg[i] = new ThreadGroup(i == 0 ? roottg : tg[i-1], Integer.toString(i));
>             for (int j = 0; j < nmbTH; j++) {
>                 threads[i][j] = new Thread_t(tg[i],Integer.toString(j));
>             }
>         }
>         for (int i = 0; i < nmbTG; i ++) {
>             for (int j = 0; j < nmbTH; j++) {
>                    threads[i][j].setDaemon(tg[i].isDaemon());
>                    threads[i][j].start();
>             }
>         }
>         for (int i = 0; i < nmbTH; i ++) {
>             threads1[i].start();
>         }
>         for (int i = 0; i < nmbTG; i++) {
>             for (int j = 0; j < nmbTH; j++) {
>                 try {
>                     threads[i][j].join();
>                 } catch (Throwable e) {
>                     e.printStackTrace();
>                 }
>             }
>         }
>         for (int i = 0; i < nmbTH; i ++) {
>             try {
>                 threads1[i].join();
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             }
>         }
>     }
> }
> class Thread_t extends Thread {
>     ThreadGroup tg;
>     String id;
>     public Thread_t (ThreadGroup tg, String n) {
>         super(tg, n);
>         this.tg = tg;
>         this.id = n;
>     }
>     public void run() {
>         int mp = tg.getMaxPriority();
>         if (ThreadGroupTest.setPrior ) {
>             tg.setMaxPriority(2); 
>         }
>         String[][] str = new String[10][100];        
>         for (int i = 0; i < str.length; ++i) {
>       
>             for (int j = 0; j < str[i].length; ++j) {
>                 str[i][j] = "" + i + "" + j;
>             }
>         }
>     }    
> }
> ------------------------------------------------------------------
> Run ThreadGroupTest several times
> I can not reproduce the issue on Windows for non daemon threads.
> But it is reproducible for daemon threads on Windows and for both kinds of thread on
Linux.
> java -cp . ThreadGroupTest true true
> 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
> Step: 0  finished
> Step: 1  finished
> Step: 2  finished
> Step: 3  finished
> Step: 4  finished
> Step: 5  finished
> Step: 6  finished
> Step: 7  finished
> Step: 8  finished
> Step: 9  finished
> Step: 10  finished
> Step: 11  finished
> Step: 12  finished
> java -cp . ThreadGroupTest false true
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or
its licensors, as applicable.
> java version "1.5.0" 
> pre-alpha : not complete or compatible
> svn = r537729, (May 14 2007), Linux/ia32/gcc 3.3.3, release build
> http://incubator.apache.org/harmony
> Step: 0  finished
> Step: 1  finished
> Step: 2  finished
> This bug causes the failure of the reliability test
> api.kernel.threadgroup.EnumerateTest
> from http://issues.apache.org/jira/browse/HARMONY-2918

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


Mime
View raw message