JDK-6327324 : SAJDI : DebuggerException thrown while reading register values on linux platform.
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 6
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-09-22
  • Updated: 2012-02-01
  • Resolved: 2005-10-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b56Fixed
Related Reports
Relates :  
Description
Problem is Linux ptrace() to get register values fails intermittently.
Opening this  bug to track the Linux problem.

Following nsk  sajdi test fails:

nsk/sajdi/ThreadReference/frame/frame002
nsk/sajdi/ThreadReference/frames/frames002
nsk/sajdi/ThreadReference/frames_ii/frames_ii002
nsk/sajdi/StackFrame/getValues/getvalues001
nsk/sajdi/StackFrame/thisObject/thisobj001
nsk/sajdi/StackFrame/visibleVariables/visibvars001
nsk/sajdi/VMCannotBeModifiedException/thrown/thrown003

And any other tests  which  tries to get thread register values
will fail with same error.
#Find frame of tested method on the thread stack
#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:238)
#	at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:197)
#	at sun.jvm.hotspot.jdi.ThreadReferenceImpl.privateFrames(ThreadReferenceImpl.java:197)
#	at sun.jvm.hotspot.jdi.ThreadReferenceImpl.frames(ThreadReferenceImpl.java:167)
#	at nsk.sajdi.VMCannotBeModifiedException.thrown.thrown003.runIt(thrown003.java:118)
#	at nsk.sajdi.VMCannotBeModifiedException.thrown.thrown003.run(thrown003.java:26)
#	at nsk.sajdi.VMCannotBeModifiedException.thrown.thrown003.main(thrown003.java:21)

Comments
SUGGESTED FIX File: $HS/agent/src/os/linux/ps_proc.c Function: ptrace_attach Line: 118 The waitpid(pid, NULL, 0) call after ptrace(PTRACE_ATTACH...) is commented out. i.e., we don't wait for the attach to "complete". The get thread regs (or any other ptrace call) will fail if we try that before attach is complete. --- Hui Huang confirmed that the waitpid() call after ptrace(PTRACE_ATTACH...) has to be uncommented. But, suggested that status and error code of waitpid be checked and error (if any) be reported. After uncommenting waitpid call and adding status/return code check, Swamy Venkataramanappa found that waitpid returns ECHILD for all non-main threads. It turns out that waitpid accepts flag that specifies which type of children are waited for. Please refer to /use/include/linux/wait.h. The following lines are from the header file wait.h: #define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads in this group */ #define __WALL 0x40000000 /* Wait on all children, regardless of type */ #define __WCLONE 0x80000000 /* Wait only on non-SIGCHLD children */ I think we need to use __WALL (or atleast include __WCLONE) in the type flag instead of 0 as third parameter to waitpid call. -Sundar
28-09-2005

EVALUATION Linux ptrace(GETREGS..) issue. This bug is opened to track linux kernel fix.
22-09-2005