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/04/12 06:33:32 UTC

[jira] Created: (HARMONY-3627) [drlvm] VM works incorrectly if several threads catch StackOverflowError

[drlvm] VM works incorrectly if several threads catch StackOverflowError
------------------------------------------------------------------------

                 Key: HARMONY-3627
                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
            Reporter: Vera Petrashkova
            Priority: Minor


When several threads expect  StackOverflowError then VM works incorrectly.
The following test demonstrates this issue.
VM crashes or finish its run abnormally.
----------------test.java-------------------
public class test extends Thread {
   public static void main (String[] argv) {
        int N_TH = 5;
        try {
            if (argv.length > 0) {
                N_TH=Integer.parseInt(argv[0]);
            }
        } catch (Throwable e) {
        }
        test t[] = new test[N_TH];
        for (int i = 0; i < N_TH; i++) {
            t[i]=new test();
            t[i].start();
        }
        try {
            for (int i = 0; i < N_TH; i++) {
                t[i].join();
            }
        } catch (Throwable e) {
            System.err.println(e);
        }

        System.out.println("Test passed");
    }
    public void m(int t) {
             m(t+1);
    }

    public void run() {
        System.err.println("Start");
        try {
            m(0);
        } catch (StackOverflowError e) {
        }
    }
}
------------------------------
Run test
java  -cp . test 20

Output:
Sometimes test passes.

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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony
Start
...
Start
Test passed

But  usually VM does not report full message and finishes execution or crashes:
Start
Start
Start



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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Ilya Berezhniuk commented on HARMONY-3627:
------------------------------------------

I agree that ihat in general it's a design issue.
My two cents for (1):
I think in future we can ask major components for required stack size in vm initialization (before vm_attach() call), and then use maximal value for setting guard page for all threads including main thread. But switching to alternate stack is difficult on Windows - JIT should support it itself.

But current issue is simply a bug - we doesn't rethrow pending thread  exception when return from recompilation.
I stepped again through code after stack overflow in native - it was in memory allocation for STL collection in EM, or in JIT compilation - but always in eb_profiler_sync_mode_callback(). VM does not crashes in native, it always successfully returns from native to Java and checks for pending thread exception to rethrow it - but see no pending exception. So I'll try to find a cause for such behavior, and will try to fix it.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Assigned: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Gregory Shimansky reassigned HARMONY-3627:
------------------------------------------

    Assignee: Gregory Shimansky

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Assignee: Gregory Shimansky
>            Priority: Minor
>         Attachments: H-3627.patch
>
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Ilya Berezhniuk commented on HARMONY-3627:
------------------------------------------

Debug printing I've inserted shows that when we set guard page, we always do this correctly - even if test crashes.
But access violation is catched under Visual Studio and under NTSD after hundreds of runs. NTSD it quite uncomfortable, so I've wrote program to press F5 in Visual Studio :) and catched access violation.

Crash occurs in native code. Seems like curcumstances are the following: when some thread has consumed almost all stack and has almost reached guard page, recursive method m() reaches particular invocation count to become 'hot' method - so recompilation is started. Thread goes into VM/JIT code, and stack overflow occurs in native code in non-unwindable area. When VEH catches stack overflow, it simply raises exception end returns CONTINUE_EXECUTION. Then recompiled method continues recursion, and stack reaches non-mapped memory - we got access violation.

I tried to run test with -Xem:jet and -Xem:opt to prevent recompilation, it doesn't crash with thousands of runs- it's an argument for described situation.

But I'm not sure absolutely and will try to assure. The argument against is that non-unwindable area is usually wrapped with BEGIN_RAISE_AREA/END_RAISE_AREA macros, and END_RAISE_AREA includes exn_rethrow_if_pending() - so raised exception should be thrown and guard page restored.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Ilya Berezhniuk commented on HARMONY-3627:
------------------------------------------

It really seems like guard page miss - while trying to access local variables in test.m() method, VM reports access violation instead of stack overflow exception.
The main question for me is why access violation exception was not catched by vectored exception handler; it's possibly because of insufficient stack space for exception processing...

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Closed: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Gregory Shimansky closed HARMONY-3627.
--------------------------------------


No response, assuming ok.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Assignee: Gregory Shimansky
>            Priority: Minor
>         Attachments: H-3627.patch
>
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Vera Petrashkova commented on HARMONY-3627:
-------------------------------------------

I can not determine if the guard page placement is causing problems.
Additionally, this issue is not reproducible on interpreter (r548364 was used on  W2003 and WinXP).
Vera P.


> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Vera Petrashkova commented on HARMONY-3627:
-------------------------------------------

This bug is still reproducible on Harmony-r547521.
Test intermittently fails.
Output:
========
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 = r547521, (Jun 15 2007), Windows/ia32/msvc 1310, release build
http://harmony.apache.org
Start
Start
Start
Start
Start
Start
Start
Start
Windows reported exception: 0xc0000005
StartRegisters:

    EAX: 0x00000000, EBX: 0x2076d760, ECX: 0x00fe2ec0, EDX: 0x0000262b
    ESI: 0x00000633, EDI: 0x0284fe80, ESP: 0x027d3004, EBP: 0x027eb090
    EIP: 0x2076d760
Start
Start
Start
Start
Stack trace:

Thanks
Vera P.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

weldon washburn commented on HARMONY-3627:
------------------------------------------

Ilya's comments above, "...goes into VM/JIT code, and stack overflow occurs in native code in non-unwindable area." leads us into an interesting area of JVM design.  In specific, how to manage stack usage when executing vm internal native code.  This problem is somewhat similar to app/kernel stack management in operating systems.  My opinion is that we do not have to solve this problem at this time.  Its probably a 2008 kind of problem.  In any case, some observations:

1)
Application code should never be able to use up basically all the stack, then do an OS call and thus cause a crash inside Linux or Windows kernel.  This would make Denial Of Service attacks very easy.  The same applies to a production JVM.
2)
The approach in OS design is to have a seperate kernel stack for each thread.  Its something like 8KB in size.  The stack is toggled back and forth as the system toggles between user and supervisor mode.  This guarantees a fixed amount of kernel stack regardless of what the app is doing.  (It also prevents the app from snooping the kernel stack but this is a distraction to the issue at hand.)

Somehow Harmony JVM needs to be designed to do something like the following in priority order:
1)
Guarantee there is enough stack for the JIT to do a compilation (or GC or whatever).  Maybe do something like switch to a special jitting stack when space is tight.  Given that jitting/gc takes a relatively long time, the cost of determining how much stack is available or even finding special stack space should not be a big performance issue.
2)
If no additional stack space is available and this is a optimizing re-jit, simply skip the compilation (the system continues to use the slow version -- graceful degradation).
3)
If jitting absolutely must be done and there is insufficient stack space, throw a StackOverflowError (this is different than a StackOverflowException).

The first step in addressing the above is to do stack sizing for each of the major subcomponents.  My guess is that the biggies are the JIT and GC.  Unless we have an interesting workload that hits the above problems, its probabaly best to leave this design issue until later.




> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Resolved: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Gregory Shimansky resolved HARMONY-3627.
----------------------------------------

    Resolution: Fixed

Patch applied at 559588. Please check that the bug is fixed for you.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Assignee: Gregory Shimansky
>            Priority: Minor
>         Attachments: H-3627.patch
>
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Pavel Pervov commented on HARMONY-3627:
---------------------------------------

I've looked through the patch and found no issues with it. Thanks.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>         Attachments: H-3627.patch
>
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

weldon washburn commented on HARMONY-3627:
------------------------------------------

hmm... I recall that somehow the stack guard page was not place at the correct address when running on winxp.  I don't recall any code in 4001 patch that addressed this issue.   Maybe this is still the problem?

Vera,
Can you try to determine if the guard page placement is causing problems?

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Updated: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Gregory Shimansky updated HARMONY-3627:
---------------------------------------

    Patch Info: [Patch Available]

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Assignee: Gregory Shimansky
>            Priority: Minor
>         Attachments: H-3627.patch
>
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Ilya Berezhniuk commented on HARMONY-3627:
------------------------------------------

Failure occurs once in 400-600 runs for r549065 on W2003.
I didn't see message about exception - it crashes silenty.

I tried to start 'java -cp . test 20000' to catch exception under debugger, but for such thread count I've got another crash because of thread ID overflow (HARMONY-4024).


> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Commented: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Rana Dasgupta commented on HARMONY-3627:
----------------------------------------

It seems to me that when this test is run with many threads and multiple times, sometimes ( even during clean exit ) the stack guard state does not get get restored correctly. So the stack area is left unguarded and next time the stack overflows into the unmapped area at the bottom of the stack. I don't think that think that this type of access violation is catchable because NT treats it as a fatal error and tears down the process. 

We can test this out by putting a debug BP or some trace messages in asm_exception_catch_callback to ensure that the guard is getting reset. I don't have time to try this out right now, sorry.

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Updated: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Gregory Shimansky updated HARMONY-3627:
---------------------------------------

    Summary: [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError  (was: [drlvm] VM works incorrectly if several threads catch StackOverflowError)

> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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


[jira] Updated: (HARMONY-3627) [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError

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

Ilya Berezhniuk updated HARMONY-3627:
-------------------------------------

    Attachment: H-3627.patch

This patch fixes this issue.
It changes behavior of type_info_get_class_no_exn() so as it cleans exception before entering classloader, and then restores exception. This patch also changes type_info_is_resolved() so as it does not invokes class loader if class is loaded already.


> [drlvm][exception] VM works incorrectly if several threads catch StackOverflowError
> -----------------------------------------------------------------------------------
>
>                 Key: HARMONY-3627
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3627
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Priority: Minor
>         Attachments: H-3627.patch
>
>
> When several threads expect  StackOverflowError then VM works incorrectly.
> The following test demonstrates this issue.
> VM crashes or finish its run abnormally.
> ----------------test.java-------------------
> public class test extends Thread {
>    public static void main (String[] argv) {
>         int N_TH = 5;
>         try {
>             if (argv.length > 0) {
>                 N_TH=Integer.parseInt(argv[0]);
>             }
>         } catch (Throwable e) {
>         }
>         test t[] = new test[N_TH];
>         for (int i = 0; i < N_TH; i++) {
>             t[i]=new test();
>             t[i].start();
>         }
>         try {
>             for (int i = 0; i < N_TH; i++) {
>                 t[i].join();
>             }
>         } catch (Throwable e) {
>             System.err.println(e);
>         }
>         System.out.println("Test passed");
>     }
>     public void m(int t) {
>              m(t+1);
>     }
>     public void run() {
>         System.err.println("Start");
>         try {
>             m(0);
>         } catch (StackOverflowError e) {
>         }
>     }
> }
> ------------------------------
> Run test
> java  -cp . test 20
> Output:
> Sometimes test passes.
> 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 = r526746, (Apr 10 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Start
> ...
> Start
> Test passed
> But  usually VM does not report full message and finishes execution or crashes:
> Start
> Start
> Start

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