jstack thread dump error: get_thread_regs failed for a lwp

Bug #597098 reported by Max Lynch
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
sun-java6 (Ubuntu)
New
Undecided
Unassigned

Bug Description

When using jstack on 9.10 x86_64 (2.6.31-302-rs #7 SMP), with sun-java6-jdk (6.20dlj-0ubuntu1.9.10) it fails with get_thread_regs failed for a lwp errors.

Example:
$ jstack -F 8812

Attaching to process ID 8819, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 16.3-b01
Deadlock Detection:

No deadlocks found.

Thread 8863: (state = BLOCKED)
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:152)
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet(LinuxDebuggerLocal.java:466)
        at sun.jvm.hotspot.debugger.linux.LinuxThread.getContext(LinuxThread.java:65)
        at sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess.getCurrentFrameGuess(LinuxAMD64JavaThreadPDAccess.java:92)
        at sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:256)
        at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:218)
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:76)
        at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
        at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
        at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.tools.jstack.JStack.runJStackTool(JStack.java:118)
        at sun.tools.jstack.JStack.main(JStack.java:84)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet0(Native Method)
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access$800(LinuxDebuggerLocal.java:51)
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1GetThreadIntegerRegisterSetTask.doit(LinuxDebuggerLocal.java:460)
        at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:127)

AFAIK this is unexpected behavior, and instead a working thread dump should be shown. Unfortunately this is my first experience with jstack so I don't know exactly what I should be seeing.

Revision history for this message
Martin Kuen (martin-kuen) wrote :

java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

ubuntu 10.04 LTS 64-bit

You must invoke jstack as the user who started/is running the given process.
The above error occurs if you invoke jstack as "root"/via sudo (Has Super Cow Powers but is still the wrong user)

I guess you tried the "-F" option, because it didn't work without it. Therefore, you tried the sledgehammer :). "-F" IS for a hung process.

If you want to create a thread dump of e.g. tomcat6 (installed from ubuntu package repo) you must type the following:

"sudo -u tomcat6 jstack 8812"

Executes jstack as user tomcat6, who is running the service tomcat6, assuming tomcat's pid is 8812.

This is not an ubuntu bug, it's - say - some sort of usability issue with this jstack thing. Blame Sun/Oracle . . .

Changed in sun-java6 (Ubuntu):
status: New → Invalid
Revision history for this message
Max (ihasmax) wrote :

Thanks for the response.

I was running this as the same user of the process, not as root.

Fortunately (but not for the resolution of this bug) my process is no longer hanging so I can't recreate it. I'll comment again if it happens again.

Changed in sun-java6 (Ubuntu):
status: Invalid → New
Revision history for this message
Jakub Milkiewicz (jmilkiewicz) wrote :

Hi

I also faced dreadful "get_thread_regs failed for a lwp .." but depending on switches to jstack and whether i run my application in IDE ( eclipse based SpringSource Tools Suite) or from gnome-terminal jstack works..

Below are my observations:
- application ran from IDE, jstack <PID>
in gnome-terminal i got: "Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding"

i can clearly see correct thread dump on eclipse console (sysout)

- application ran from IDE, jstack -F <PID>
in terminal i got: "Attaching to process ID 3744, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0-b16
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp ..."
on eclipse console (sysout/syserr) i see no stackTrace

- application ran from gnome-terminal, jstack <PID>
in terminal i got correct thread dump. application sysout/syserr is clear

- application ran from gnome-terminal, jstack -F <PID>
in terminal i got "Attaching to process ID 4265, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0-b16
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp ..."
application sysout/syserr is clear

Ubuntu 10.04.1 LTS

uname -a:
2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:05:27 UTC 2010 x86_64 GNU/Linux

java -version:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)

Revision history for this message
Andrew Ball (anball-gmail) wrote :

For Tomcat, I was able to use "kill -3 <tomcat_pid>" as a workaround. I got basically the same behavior with OpenJDK on Ubuntu 10.10 x86_64.

Revision history for this message
Nathan Smith (nace) wrote :

I am seeing the exact same behavior on CentOS 5.4 x64, so not necessarily Ubuntu-specific:

# uname -a
Linux ip-#-#-#-# 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

# java -version
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)

(server: Jetty 7.4.5)

The "get_thread_regs failed for a lwp" errors occur regardless of whether I invoke jstack as root or as the user that java is running as.

Does anyone have any updates on this? There's not much online about it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.