Description of problem: unable to run jstack (Sun's reporting tool) on any Java process on AS 4 systems. Runs fine on earlier versions of RedHat, Fedora Core 4 and on current non-RedHat Linuxes. Version-Release number of selected component (if applicable): Red Hat Enterprise Linux AS release 4 (Nahant Update 1) Sun JDK 1.5.0.06 How reproducible: Always Steps to Reproduce: 1. run any Java program using Suns JDK 2. run {where java is}/bin/jstack pid-of-the-java-process 3.geet exception Actual results: Attaching to process ID 29417, please wait... Debugger attached successfully. Server compiler detected. JVM version is 1.5.0_05-b05 Thread 30393: (state = IN_NATIVE) Error occurred during stack walking: sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:134) at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet(LinuxDebuggerLocal.java:437) at sun.jvm.hotspot.debugger.linux.LinuxThread.getContext(LinuxThread.java:48) at sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess.getCurrentFrameGuess(LinuxX86JavaThreadPDAccess.java:75) at sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:252) at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:211) at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:50) at sun.jvm.hotspot.tools.JStack.run(JStack.java:41) at sun.jvm.hotspot.tools.Tool.start(Tool.java:204) at sun.jvm.hotspot.tools.JStack.main(JStack.java:58) Caused by: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp Expected results: should print list of threads and what they are doing Additional info:
That sounds more like a glibc problem. The component basesystem refers to the package basesystem which provides a skeleton for a Red Hat Linux system. Reassigning bug to glibc. Read ya, Phil
Can you please attach strace -f output of the jstack process? It can be anything, from a kernel problem, glibc or hotspot bug.
Created attachment 125628 [details] output of strace -f jstack pid output of strace -f jstack pid
All the indications in that trace point to a misuse of ptrace, or perhaps a problem with ptrace or some other kernel issue. There is no sign of anything relating to glibc here. I wonder what the trace from a system where it works right shows. This trace makes it look like the program is not doing the right things to handle multiple threads via ptrace at all.
Created attachment 125760 [details] output of strace -f jstack on other OS As requested, attaching output of strace -f jstack pid from other Linux as similar to RedHat as I could find: CentOs running 2.6.9-22.EL (where jstack works as expected)
That trace shows it writing out the same sort of error messages you cite as being the problem.
you are right, the format is the same - a Java stack trace. Only in the "bad" case it represents the actual exception thrown from the tool with the message "get_thread_regs failed for a lwp" and in the "good" case it is just a stack trace showing what this thread is doing at the moment. Example of "good" output: Thread 3947: (state = BLOCKED) - java.lang.Object.wait(long) @bci=0 (Interpreted frame) - java.lang.Object.wait() @bci=2, line=474 (Interpreted frame) - org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run() @bci=26, line =656 (Interpreted frame) - java.lang.Thread.run() @bci=11, line=595 (Interpreted frame)
Your second trace shows writing out these messages: Error occurred during stack walking: sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp etc. Those are what I've described as the same sort of error messages you've cited as being the problem. Please attach a trace from a run that does not produce such errors.
No response in 2 month and no signs of a bug in anything but jstack (its incorrect use of ptrace).