Name: tb29552 Date: 10/01/2003
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_09-b03)
Java HotSpot(TM) Client VM (build 1.3.1_09-b03, mixed mode)
FULL OS VERSION :
Linux axe 2.4.20 #7 Sat Mar 8 15:08:24 GMT 2003 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
After setuid is called successfully from native code, all JVM
thread operations cause a total hang.
Whilst trying to get native user suport in orion server configured
I found a 100% cpu loop where the only active thread was doing the
following and nothing else in the JVM was responding:
#0 0x40130cb7 in sched_yield () from /lib/libc.so.6
#1 0x403f5fbd in os::yield_all () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#2 0x40412981 in SafepointSynchronize::begin () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#3 0x4045d9f9 in VMThread::loop () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#4 0x4045d76a in VMThread::run () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#5 0x403f7005 in _start () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#6 0x40020bf0 in pthread_start_thread () from /lib/libpthread.so.0
In attempting to reproduce the bug I was able to reproduce a hang, but
not a busy-wait hang. The trace (which I assume is extremely closely
related to the above) that I have been able to reproduce is:
#0 0x40023354 in __pthread_sigsuspend () from /lib/libpthread.so.0
#1 0xbfffd738 in ?? ()
#2 0x40023118 in __pthread_wait_for_restart_signal () from /lib/libpthread.so.0
#3 0x4001fcbb in pthread_cond_wait@GLIBC_2.0 () from /lib/libpthread.so.0
#4 0x403f532d in os::Linux::safe_cond_wait () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#5 0x403e6198 in Monitor::wait () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#6 0x4043b121 in SuspendCheckerThread::stop () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#7 0x4043e3e5 in Threads::destroy_vm () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#8 0x4036494e in jni_DestroyJavaVM () from /usr/local/j2sdk1.4.2_01/jre/lib/i386/client/libjvm.so
#9 0x080496cf in strcpy ()
#10 0x40083e3e in __libc_start_main () from /lib/libc.so.6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Steps:
1) javac ThreadHang.java
2) javah ThreadHang
3) gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux ThreadHangImp.c -shared -o libhang.so
4) As root, run java -Djava.library.path=. ThreadHang
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No output and clean exit
ACTUAL -
No output and complete hang, kill -3 does not respond, etc
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
ThreadHang.java:
public class ThreadHang
{
public static void main(String[] args) {
System.loadLibrary("hang");
setUid("orion");
}
private static native void setUid(String user);
}
---
ThreadHangImp.c:
#include <jni.h>
#include <pwd.h>
#include "ThreadHang.h"
JNIEXPORT void JNICALL Java_ThreadHang_setUid
(JNIEnv *env, jclass class, jstring username)
{
const char *utfname;
struct passwd *user;
utfname = (*env)->GetStringUTFChars(env, username, 0);
user = getpwnam(utfname);
setuid(user->pw_uid);
(*env)->ReleaseStringUTFChars(env, username, utfname);
}
---------- END SOURCE ----------
(Review ID: 209571)
======================================================================
- relates to
-
JDK-4279545 (process) support setuid/setgid
- Open