United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6201185 FATAL ERROR in native method: JNI call made with exception pending at java.lang.Thread.sleep(NativeM
6201185 : FATAL ERROR in native method: JNI call made with exception pending at java.lang.Thread.sleep(NativeM

Details
Type:
Bug
Submit Date:
2004-11-29
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2004-12-02
Component:
hotspot
OS:
solaris,linux,generic
Sub-Component:
runtime
CPU:
generic
Priority:
P1
Resolution:
Fixed
Affected Versions:
1.4.2_07,5.0u2,6
Fixed Versions:
1.4.2_07

Related Reports
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
One more issue with the strict jni checks added for checking pending 
exceptions before making jni calls. (Note: These failures occur with and 
without 5101288 fix)

We are seeing JCK failures of two kinds; one in Thread.sleep() and 
another in Object,wait().

(You can access jck testcase 
javasoft.sqe.test.api.java.lang.Thread.isAliveTests and 
javasoft.sqe.test.api.java.io.PipedOutputStream.WriteTests from 
/net/jlab113.india/export/jpse/pb131437/jck/ )

FATAL ERROR in native method: JNI call made with exception pending
         at java.lang.Thread.sleep(Native Method)

FATAL ERROR in native method: JNI call made with exception pending
         at java.lang.Object.wait(Native Method)

The first failure (in Thread.sleep):
=================================
In JVM_Sleep(), vm checks if there is a pending exception, when it does 
not find any, it calls 
THROW_MSG(vmSysmbols::java_lang_interruptedException(), "sleep 
interrupted");

And while handling this exception, VM installs another exception, shown 
in following trace:

-->>Thread::set_pending_exception(oopDesc * 0x102ab318, const char * 
0x0865595c, int 1395) line 426
JavaThread::check_and_handle_async_exceptions(int 1) line 1397
JavaThread::handle_special_runtime_exit_condition(int 1) line 1458
ThreadToNativeFromVM::ThreadToNativeFromVM(JavaThread * 0x00790248) line 
199
Verifier::verify_byte_codes(instanceKlassHandle {...}, Thread * 
0x00790248) line 168
instanceKlass::verify_code(instanceKlassHandle {...}, Thread * 
0x00790248) line 97 + 13 bytes
instanceKlass::link_class_impl(instanceKlassHandle {...}, Thread * 
0x00790248) line 216 + 13 bytes
instanceKlass::link_class(Thread * 0x00790248) line 166 + 13 bytes
instanceKlass::initialize_impl(instanceKlassHandle {...}, Thread * 
0x00790248) line 243 + 19 bytes
instanceKlass::initialize(Thread * 0x00790248) line 85 + 13 bytes
Exceptions::new_exception(Thread * 0x00790248, symbolHandle {...}, 
symbolHandle {...}, JavaCallArguments * 0x1858faf0, Handle {...}, Hand
le {...}) line 170
Exceptions::new_exception(Thread * 0x00790248, symbolHandle {...}, const 
char * 0x085cdd9c, Handle {...}, Handle {...}) line 225 + 36 byt
es
Exceptions::_throw_msg(Thread * 0x00790248, const char * 0x085cddb0, int 
2061, symbolHandle {...}, const char * 0x085cdd9c, Handle {...},
  Handle {...}) line 97 + 29 bytes
Exceptions::_throw_msg(Thread * 0x00790248, const char * 0x085cddb0, int 
2061, symbolOopDesc * 0x14271a40, const char * 0x085cdd9c) line
107 + 33 bytes
JVM_Sleep(JNIEnv_ * 0x007902f4, _jclass * 0x1858fc34, __int64 60000) 
line 2061 + 30 bytes
00fb9cc8()
00fb2ed3()
00fb31d9()
00fb0275()
JavaCalls::call_helper(JavaValue * 0x1858fefc, methodHandle * 
0x1858fde8, JavaCallArguments * 0x1858fe50, Thread * 0x00790248) line 
373 + 54 bytes
os::os_exception_wrapper(void (JavaValue *, methodHandle *, 
JavaCallArguments *, Thread *)* 0x08011919 JavaCalls::call_helper(class 
JavaValue *,class methodHandle *,class JavaCallArguments *,class Thread 
*), JavaValue * 0x1858fefc, methodHandle * 0x1858fde8, JavaCallArgumen
ts * 0x1858fe50, Thread * 0x00790248) line 53 + 19 bytes
JavaCalls::call(JavaValue * 0x1858fefc, methodHandle {...}, 
JavaCallArguments * 0x1858fe50, Thread * 0x00790248) line 300 + 26 bytes
JavaCalls::call_virtual(JavaValue * 0x1858fefc, KlassHandle {...}, 
symbolHandle {...}, symbolHandle {...}, JavaCallArguments * 0x1858fe50
, Thread * 0x00790248) line 187 + 21 bytes
JavaCalls::call_virtual(JavaValue * 0x1858fefc, Handle {...}, 
KlassHandle {...}, symbolHandle {...}, symbolHandle {...}, Thread * 
0x00790248) line 193 + 29 bytes
thread_entry(JavaThread * 0x00790248, Thread * 0x00790248) line 1848 + 
68 bytes
JavaThread::thread_main_inner() line 1136 + 18 bytes
JavaThread::run() line 1123
_start(Thread * 0x00790248) line 290
_threadstartex(void * 0x00791b40) line 212 + 13 bytes
KERNEL32! 77f04ede()


===>>>Now, VM enters functionEnter()  in jniCheck.cpp with a pending 
exception:

-->>functionEnter(JavaThread * 0x00790248) line 156
checked_jni_NewGlobalRef(JNIEnv_ * 0x007902f4, _jobject * 0x00782e4c) 
line 554 + 9 bytes
class_to_ID(context_type * 0x1858f524, _jobject * 0x00782e4c, unsigned 
char 1) line 558 + 16 bytes
make_loadable_class_info(context_type * 0x1858f524, _jobject * 
0x00782e4c) line 647 + 15 bytes
VerifyClass(const JNINativeInterface_ * * 0x007902f4, _jobject * 
0x00782e4c, char * 0x1858f764, long 256) line 725 + 13 bytes
VerifyClassCodes(const JNINativeInterface_ * * 0x007902f4, _jobject * 
0x00782e4c, char * 0x1858f764, long 256) line 47 + 22 bytes
Verifier::verify_byte_codes(instanceKlassHandle {...}, Thread * 
0x00790248) line 168 + 29 bytes
instanceKlass::verify_code(instanceKlassHandle {...}, Thread * 
0x00790248) line 97 + 13 bytes
instanceKlass::link_class_impl(instanceKlassHandle {...}, Thread * 
0x00790248) line 216 + 13 bytes
instanceKlass::link_class(Thread * 0x00790248) line 166 + 13 bytes
instanceKlass::initialize_impl(instanceKlassHandle {...}, Thread * 
0x00790248) line 243 + 19 bytes
instanceKlass::initialize(Thread * 0x00790248) line 85 + 13 bytes
Exceptions::new_exception(Thread * 0x00790248, symbolHandle {...}, 
symbolHandle {...}, JavaCallArguments * 0x1858faf0, Handle {...}, Hand
le {...}) line 170
Exceptions::new_exception(Thread * 0x00790248, symbolHandle {...}, const 
char * 0x085cdd9c, Handle {...}, Handle {...}) line 225 + 36 bytes
Exceptions::_throw_msg(Thread * 0x00790248, const char * 0x085cddb0, int 
2061, symbolHandle {...}, const char * 0x085cdd9c, Handle {...},
  Handle {...}) line 97 + 29 bytes
Exceptions::_throw_msg(Thread * 0x00790248, const char * 0x085cddb0, int 
2061, symbolOopDesc * 0x14271a40, const char * 0x085cdd9c) line
107 + 33 bytes
JVM_Sleep(JNIEnv_ * 0x007902f4, _jclass * 0x1858fc34, __int64 60000) 
line 2061 + 30 bytes


=====>>>>>> Should we not skip the installation of async exception while 
transtioning from VM to Native also as we did in 5101288 for 
native_trans (Native to VM) ?? Or something else is wrong???

You can run the testcase as below:
java -Xfuture -Xcheck:jni 
javasoft.sqe.tests.api.java.lang.Thread.isAliveTests

Note: the problem reproduces only with -Xfuture


Second failure (in Object.wait())
================================

This is also due to pending exception being installed by VM when thread 
is going to Native for VM

-->>Thread::set_pending_exception(oopDesc * 0x102be5c0, const char * 
0x0865595c, int 1395) line 426
JavaThread::check_and_handle_async_exceptions(int 1) line 1397
JavaThread::handle_special_runtime_exit_condition(int 1) line 1458
ThreadToNativeFromVM::ThreadToNativeFromVM(JavaThread * 0x00791a58) line 199
Verifier::verify_byte_codes(instanceKlassHandle {...}, Thread * 
0x00791a58) line 168
instanceKlass::verify_code(instanceKlassHandle {...}, Thread * 
0x00791a58) line 97 + 13 bytes
instanceKlass::link_class_impl(instanceKlassHandle {...}, Thread * 
0x00791a58) line 216 + 13 bytes
instanceKlass::link_class(Thread * 0x00791a58) line 166 + 13 bytes
instanceKlass::initialize_impl(instanceKlassHandle {...}, Thread * 
0x00791a58) line 243 + 19 bytes
instanceKlass::initialize(Thread * 0x00791a58) line 85 + 13 bytes
Exceptions::new_exception(Thread * 0x00791a58, symbolHandle {...}, 
symbolHandle {...}, JavaCallArguments * 0x187cfa40, Handle {...}, Hand
le {...}) line 170
Exceptions::new_exception(Thread * 0x00791a58, symbolHandle {...}, const 
char * 0x00000000, Handle {...}, Handle {...}) line 225 + 36 bytes
Exceptions::_throw_msg(Thread * 0x00791a58, const char * 0x0860fd4c, int 
298, symbolHandle {...}, const char * 0x00000000, Handle {...},
Handle {...}) line 97 + 29 bytes
Exceptions::_throw_msg(Thread * 0x00791a58, const char * 0x0860fd4c, int 
298, symbolOopDesc * 0x14271a40, const char * 0x00000000) line 1
07 + 33 bytes
ObjectMonitor::wait(__int64 1000, int 1, Thread * 0x00791a58) line 298 + 
27 bytes
ObjectSynchronizer::wait(Handle {...}, __int64 1000, Thread * 
0x00791a58) line 380
JVM_MonitorWait(JNIEnv_ * 0x00791b04, _jobject * 0x187cfc40, __int64 
1000) line 387 + 21 bytes


===>>>And in functionEnter, VM find a pending exception while calling 
checked_jni_NewGlobalRef:

->>functionEnter(JavaThread * 0x00791a58) line 156
checked_jni_NewGlobalRef(JNIEnv_ * 0x00791b04, _jobject * 0x00782e4c) 
line 554 + 9 bytes
class_to_ID(context_type * 0x187cf474, _jobject * 0x00782e4c, unsigned 
char 1) line 558 + 16 bytes
make_loadable_class_info(context_type * 0x187cf474, _jobject * 
0x00782e4c) line 647 + 15 bytes
VerifyClass(const JNINativeInterface_ * * 0x00791b04, _jobject * 
0x00782e4c, char * 0x187cf6b4, long 256) line 725 + 13 bytes
VerifyClassCodes(const JNINativeInterface_ * * 0x00791b04, _jobject * 
0x00782e4c, char * 0x187cf6b4, long 256) line 47 + 22 bytes
Verifier::verify_byte_codes(instanceKlassHandle {...}, Thread * 
0x00791a58) line 168 + 29 bytes
instanceKlass::verify_code(instanceKlassHandle {...}, Thread * 
0x00791a58) line 97 + 13 bytes
instanceKlass::link_class_impl(instanceKlassHandle {...}, Thread * 
0x00791a58) line 216 + 13 bytes
instanceKlass::link_class(Thread * 0x00791a58) line 166 + 13 bytes
instanceKlass::initialize_impl(instanceKlassHandle {...}, Thread * 
0x00791a58) line 243 + 19 bytes
instanceKlass::initialize(Thread * 0x00791a58) line 85 + 13 bytes
Exceptions::new_exception(Thread * 0x00791a58, symbolHandle {...}, 
symbolHandle {...}, JavaCallArguments * 0x187cfa40, Handle {...}, Hand
le {...}) line 170
Exceptions::new_exception(Thread * 0x00791a58, symbolHandle {...}, const 
char * 0x00000000, Handle {...}, Handle {...}) line 225 + 36 byt
es
Exceptions::_throw_msg(Thread * 0x00791a58, const char * 0x0860fd4c, int 
298, symbolHandle {...}, const char * 0x00000000, Handle {...},
Handle {...}) line 97 + 29 bytes
Exceptions::_throw_msg(Thread * 0x00791a58, const char * 0x0860fd4c, int 
298, symbolOopDesc * 0x14271a40, const char * 0x00000000) line 1
07 + 33 bytes
ObjectMonitor::wait(__int64 1000, int 1, Thread * 0x00791a58) line 298 + 
27 bytes
ObjectSynchronizer::wait(Handle {...}, __int64 1000, Thread * 
0x00791a58) line 380
JVM_MonitorWait(JNIEnv_ * 0x00791b04, _jobject * 0x187cfc40, __int64 
1000) line 387 + 21 bytes




                                    

Comments
SUGGESTED FIX

=====>>>>>> Should we not skip the installation of async exception while 
transtioning from VM to Native also as we did in 5101288 for 
native_trans (Native to VM) ?? Or something else is wrong???

Please let me know if we need to omit the setting of pending exception 
in ThreadToNativeFromVM to fix these failures.

Suggestion/query from Poonam.Bajaj

###@###.### 2004-11-29 17:46:43 GMT

The following delta fixes the failures,
unfortunately the 1st change ( at 185 ) introduces the possibility that
it may cause an async exception to be delayed when the thread is in native
state for too long.  We are investigating the need for backporting changes
from 1.5 to mitigate this.

------- interfaceSupport.hpp -------
*** /tmp/sccs.OuayWJ	Mon Nov 29 20:35:11 2004
--- interfaceSupport.hpp	Mon Nov 29 17:07:21 2004
***************
*** 1,5 ****
  #ifdef USE_PRAGMA_IDENT_HDR
! #pragma ident "%W% %E% %U% JVM"
  #endif
  /*
   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
--- 1,5 ----
  #ifdef USE_PRAGMA_IDENT_HDR
! #pragma ident "@(#)interfaceSupport.hpp	1.152 04/11/29 16:58:51 JVM"
  #endif
  /*
   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
***************
*** 182,188 ****
        _thread->reguard_stack();
      }
      // Check for pending. async. exceptions or suspends.
!     if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition();
    }
  };
  
--- 182,188 ----
        _thread->reguard_stack();
      }
      // Check for pending. async. exceptions or suspends.
!     if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false);
    }
  };
  
***************
*** 195,201 ****
      assert(!thread->owns_locks(), "must release all locks when leaving VM");
      trans(_thread_in_vm, _thread_in_native);
      // Check for pending. async. exceptions or suspends.
!     if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition();
    }
  
    ~ThreadToNativeFromVM() { 
--- 195,201 ----
      assert(!thread->owns_locks(), "must release all locks when leaving VM");
      trans(_thread_in_vm, _thread_in_native);
      // Check for pending. async. exceptions or suspends.
!     if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false);
    }
  
    ~ThreadToNativeFromVM() { 

###@###.### 2004-11-30 14:56:10 GMT
                                     
2004-11-29
EVALUATION

From :
#! /bin/sh
test=javasoft.sqe.tests.api.java.io.PipedOutputStream.WriteTests
tpwd=/net/altair.east/eng/chrisphi/jpse/bugtraq/6193413
PATH="`pwd`/j2sdk1.4.2_07/bin:${PATH}"
export PATH
CLASSPATH=/net/latte.ireland/export/home4/jck/JCK-runtime-14a/classes
export CLASSPATH
/net/castor.east/tools/devtools/sparc/SUNWspro/SOS8/bin/dbx -r $tpwd/j2sdk1.4.2_07/bin/java_g \
    -XX:+TraceExceptions \
         -Xcheck:jni -Djava.awt.headless=false -Xfuture \
	 -Djava.security.policy=/net/latte.ireland/export/home4/jck/JCK-runtime-14a/lib/jck.policy \
	 javasoft.sqe.tests.api.java.io.PipedOutputStream.WriteTests \
	 -TestCaseID ALL

...
Exception <a 'java/lang/ClassNotFoundException'> (0xf104d920)
 thrown in interpreter method <{method} 'loadClass' '(Ljava/lang/String;Z)Ljava/lang/Class;' in 'java/lang/ClassLoader'>
 at bci 23 for thread 0x0004d8c8
Pending Async. exception installed of type: java.lang.ThreadDeath
Async. exception installed at runtime exit of type: java.lang.ThreadDeath
FATAL ERROR in native method: JNI call made with exception pending
	at java.lang.Object.wait(Native Method)
Java HotSpot(TM) Client VM warning: oopmap should only be accessed by the VM, GC task or CMS threads (or during debugging)
oop map for {method} 'wait' '(J)V' in 'java/lang/Object' @ 0 = [3] { 0 }
	- waiting on <0xf104c338> (a java.io.PipedInputStream)
	at java.io.PipedInputStream.read(PipedInputStream.java:229)
	- locked <0xf104c338> (a java.io.PipedInputStream)
	at javasoft.sqe.tests.api.java.io.PipedOutputStream.LazyReader.run(LazyReader.java:33)

###@###.### 2004-11-29 18:30:15 GMT

From :
#! /bin/sh
test=javasoft.sqe.tests.api.java.lang.Thread.isAliveTests
tpwd=/net/altair.east/eng/chrisphi/jpse/bugtraq/6193413
PATH="`pwd`/j2sdk1.4.2_07/bin:${PATH}"
export PATH
CLASSPATH=/net/latte.ireland/export/home4/jck/JCK-runtime-14a/classes
export CLASSPATH
/net/castor.east/tools/devtools/sparc/SUNWspro/SOS8/bin/dbx -r $tpwd/j2sdk1.4.2_07/bin/java_g \
    -XX:+TraceExceptions \
         -Xcheck:jni -Djava.awt.headless=false -Xfuture \
	 -Djava.security.policy=/net/latte.ireland/export/home4/jck/JCK-runtime-14a/lib/jck.policy \
	 javasoft.sqe.tests.api.java.lang.Thread.isAliveTests \
	  -TestCaseID ALL
...
Exception <a 'java/lang/ClassNotFoundException'> (0xf103a400)
 thrown in interpreter method <{method} 'loadClass' '(Ljava/lang/String;Z)Ljava/lang/Class;' in 'java/lang/ClassLoader'>
 at bci 23 for thread 0x0004d8c8
Pending Async. exception installed of type: javasoft.sqe.tests.api.java.lang.Thread.isAlive0102e
Async. exception installed at runtime exit of type: javasoft.sqe.tests.api.java.lang.Thread.isAlive0102e
FATAL ERROR in native method: JNI call made with exception pending
	at java.lang.Thread.sleep(Native Method)
	at javasoft.sqe.tests.api.java.lang.Thread.isAlive0102r.run(isAliveTests.java:156)
	- locked <0xf103b120> (a javasoft.sqe.tests.api.java.lang.Thread.isAlive0102r)
	at java.lang.Thread.run(Thread.java:534)

###@###.### 2004-11-29 19:05:57 GMT

We have a fix which addresses the failures in the jck. 
Unfortunately this may introduce a further dependency
on a more complex change in 1.5. We are investigating that
change and its requirements.

###@###.### 2004-11-30 14:56:09 GMT
                                     
2004-11-29



Hardware and Software, Engineered to Work Together