assert(_exception_caught == false) failed: _exception_caught is out of phase

Daniel D. Daugherty daniel.daugherty at oracle.com
Tue Aug 11 18:38:26 UTC 2015


Adding serviceability-dev at ... since this JVM/TI...

Dan


On 8/11/15 9:06 AM, Reingruber, Richard wrote:
> Hi,
>
> I would like to report that the assertion
>
>     assert(_exception_caught == false) failed: _exception_caught is out of phase
>
> at jvmtiThreadState.hpp:170 fires when running the command
>
>     ./images/jdk/bin/java -agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n -Xbatch ExceptionCaughtOutOfPhaseAssertion
>
> (when analyzing you might want to add -XX:-TieredCompilation -XX:-Inline '-XX:CompileCommand=compileonly *::run')
>
> Source Code:
>
>     import java.security.AccessController;
>     import java.security.PrivilegedAction;
>     
>     public class ExceptionCaughtOutOfPhaseAssertion {
>     
>         public static void main(String[] args) {
>             PrivilegedAction action = new HotThrowingAction();
>             System.out.println("### Warm-up");
>             for(int i=0; i<11000; i++) {
>                 try {
>                     action.run(); // call run() to get it compiled
>                 } catch(Throwable t) { /* ignored */ }
>             }
>             System.out.println("### Warm-up done");
>             System.out.println("### Executing privileged action");
>             AccessController.doPrivileged(action);
>         }
>         
>         public static class HotThrowingAction implements PrivilegedAction {
>             public Object run() {
>                 throw new Error();
>             }
>         }
>     }
>     
> My Analysis:
>
> * Error is thrown in interpreted activation of run()
>    - JvmtiThreadState::_exception_detected is set to true
>    - JvmtiThreadState::_exception_caught   is set to false
> * Error is caught in main() method
>    - JvmtiThreadState::_exception_detected is set to false
>    - JvmtiThreadState::_exception_caught   is set to true
> * run() method is compiled
> * PrivilegedAction is executed
> * compiled activation of run() method
>    - Error object is allocated and initialized
>    - JavaThread::_should_post_on_exceptions_flag is checked and found to be false
>      -> *no* uncommon trap
>    - compiled frame is popped, rethrow stub calls OptoRuntime::rethrow_C()
>    - _exception_detected is *not* set, remains false
>    - _exception_caught is still true
> * Java call in JVM_DoPrivileged() returns with pending exception
> * CLEAR_PENDING_EXCEPTION triggers the assertion
>
> How to Fix? I'm not really an expert in this area, but here are my two cent:
>
> (a) Improve the assertion ...but how?! Toggling JVMTI exception notifications does not seem
>      to be synchronized with java execution.
>
> (b) Calling JvmtiExport::post_exception_throw() in OptoRuntime::rethrow_C() is probably not possible,
>      because of the JRT_LEAF comment for rethrow_C(), but _exception_detected = true could be set.
>
> (c) Remove the assertion.
>
> I guess (b) could be acceptable.
>
> What do you think?
>
> Best regards,
> Richard.



More information about the serviceability-dev mailing list