JDK-7003789 : PTRACE_GETREGS problems with SA on Linux.
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-12-01
  • Updated: 2011-04-23
  • Resolved: 2011-04-23
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 JDK 7 Other
6u25Fixed 7Fixed hs20Fixed
Description
kproc64.sh fails, the output below is with
LIBSAPROC_DEBUG=TRUE



Thread 18728: (state = BLOCKED, current Java SP = 0x00007ff8ec230590
)
libsaproc DEBUG: ptrace(PTRACE_GETREGS, ...) not supported
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.Tool.start(Tool.java:221)
	at sun.jvm.hotspot.tools.StackTrace.main(StackTrace.java:130)
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)

Locked ownable synchronizers:
    - None

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/hotspot/rev/401fbd7ff77c
25-12-2010

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/401fbd7ff77c
10-12-2010

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/401fbd7ff77c
09-12-2010

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/401fbd7ff77c
08-12-2010

SUGGESTED FIX NO... I'd misread the original. Here's the intended fix: --- a/agent/src/os/linux/ps_proc.c +++ b/agent/src/os/linux/ps_proc.c @@ -121,15 +121,13 @@ static bool process_get_lwp_regs(struct #define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, data, addr) #endif -#ifdef _LP64 -#ifdef PTRACE_GETREGS64 +#if defined(_LP64) && defined(PTRACE_GETREGS64) #define PTRACE_GETREGS_REQ PTRACE_GETREGS64 +#elif defined(PTRACE_GETREGS) +#define PTRACE_GETREGS_REQ PTRACE_GETREGS +#elif defined(PT_GETREGS) +#define PTRACE_GETREGS_REQ PT_GETREGS #endif -#else -#if defined(PTRACE_GETREGS) || defined(PT_GETREGS) -#define PTRACE_GETREGS_REQ PTRACE_GETREGS -#endif -#endif /* _LP64 */ #ifdef PTRACE_GETREGS_REQ if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) {
03-12-2010

PUBLIC COMMENTS As this appears to be 64-bit isn't the problem that PTRACE_GETREGS64 is not defined?
02-12-2010

EVALUATION On x64 Linux we have PTRACE_GETREGS or PT_GETREGS defined but not any kind of ..GETREGS64, so adjust the ifdefs to cope with this and define PTRACE_GETREGS_REQ. (edited)
01-12-2010

SUGGESTED FIX UPDATED: $ hg diff agent/src/os/linux/ps_proc.c diff --git a/agent/src/os/linux/ps_proc.c b/agent/src/os/linux/ps_proc.c --- a/agent/src/os/linux/ps_proc.c +++ b/agent/src/os/linux/ps_proc.c @@ -124,10 +124,10 @@ static bool process_get_lwp_regs(struct #ifdef _LP64 #ifdef PTRACE_GETREGS64 #define PTRACE_GETREGS_REQ PTRACE_GETREGS64 -#endif -#else -#if defined(PTRACE_GETREGS) || defined(PT_GETREGS) +#elif defined(PTRACE_GETREGS) #define PTRACE_GETREGS_REQ PTRACE_GETREGS +#elif defined (PT_GETREGS) +#define PTRACE_GETREGS_REQ PT_GETREGS #endif #endif /* _LP64 */
01-12-2010

PUBLIC COMMENTS libsaproc DEBUG: ptrace(PTRACE_GETREGS, ...) not supported suggests we lack a definition for PTRACE_GETREGS_REQ in agent/src/os/linux/ps_proc.c
01-12-2010