United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7003789 PTRACE_GETREGS problems with SA on Linux.
JDK-7003789 : PTRACE_GETREGS problems with SA on Linux.

Details
Type:
Bug
Submit Date:
2010-12-01
Status:
Closed
Updated Date:
2011-04-23
Project Name:
JDK
Resolved Date:
2011-04-23
Component:
hotspot
OS:
generic
Sub-Component:
svc
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs20 (b04)

Related Reports
Backport:
Backport:

Sub Tasks

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
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 */
                                     
2010-12-01
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
                                     
2010-12-01
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)
                                     
2010-12-01
PUBLIC COMMENTS

As this appears to be 64-bit isn't the problem that PTRACE_GETREGS64 is not defined?
                                     
2010-12-02
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) {
                                     
2010-12-03
EVALUATION

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

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

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

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



Hardware and Software, Engineered to Work Together