From owner-freebsd-java@FreeBSD.ORG Fri Feb 4 02:11:23 2011 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 295EB106564A; Fri, 4 Feb 2011 02:11:23 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-java@freebsd.org Date: Thu, 3 Feb 2011 21:11:10 -0500 User-Agent: KMail/1.6.2 References: <201101261721.58069.jkim@FreeBSD.org> <1296756549.2298.3.camel@mjakubik-laptop> <201102031624.38310.jkim@FreeBSD.org> In-Reply-To: <201102031624.38310.jkim@FreeBSD.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201102032111.13479.jkim@FreeBSD.org> Cc: Pieter de Goeje , Mike Jakubik Subject: Re: [CFT] Update OpenJDK6 to b21 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2011 02:11:23 -0000 On Thursday 03 February 2011 04:24 pm, Jung-uk Kim wrote: > On Thursday 03 February 2011 01:09 pm, Mike Jakubik wrote: > > On Wed, 2011-02-02 at 13:54 -0500, Jung-uk Kim wrote: > > > Yeah, I actually fixed that. Some patches were missing in b20 > > > ports. 'jstack -m' should work, too. :-) > > > > > > Thanks for testing! > > > > Compiled OK and working with my applications OK. The jstack -m > > option you mention however produces the following results here: > > > > Attaching to process ID 84046, please wait... > > Debugger attached successfully. > > Server compiler detected. > > JVM version is 19.0-b09 > > sun.jvm.hotspot.debugger.DebuggerException: > > sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs > > failed for a lwp > > at sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal > > $BsdDebuggerLocalWorkerThread.execute(BsdDebuggerLocal.java:152) > > at > > sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal.getThreadIntegerReg > >is terSet(BsdDebuggerLocal.java:466) at > > sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java: > >65 ) at > > sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess.getC > >ur rentFrameGuess(BsdAMD64JavaThreadPDAccess.java:92) at > > sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThrea > >d. java:256) at > > sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThrea > >d. java:218) at > > sun.jvm.hotspot.tools.PStack.initJFrameCache(PStack.java:208) at > > sun.jvm.hotspot.tools.PStack.run(PStack.java:66) > > at sun.jvm.hotspot.tools.PStack.run(PStack.java:53) > > at sun.jvm.hotspot.tools.PStack.run(PStack.java:48) > > 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(NativeMethodAccessorI > >mp l.java:57) at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA > >cc essorImpl.java:43) at > > java.lang.reflect.Method.invoke(Method.java:616) > > at sun.tools.jstack.JStack.runJStackTool(JStack.java:136) > > at sun.tools.jstack.JStack.main(JStack.java:102) > > Yeah, I noticed that, too. It seems it's getting bogus thread IDs. > It'll take some time for me to figure out why, though. :-( Now I know why but it is a very complicated problem. :-( Basically, the culprit was difference between Linux and BSD, mostly _thread_id and ptrace(2). Linux has gettid(2), which returns a (32-bit) pid_t type, and it is used for _thread_id. Linux code simply calls ptrace(PTRACE_GETREGS, ...) with it and it works fine. However, BSD does not have gettid(), so we used pthread_t instead. Alas, we copied process_get_lwp_regs() from Linux-specific file. It does not work for us because _thread_id is a pthread_t type and ptrace() does not understand it. Unfortunately, there is no easy way to map pthread_t to a lwpid_t value, either. More worse, it gets truncated to 32-bit on amd64. Grrr... Jung-uk Kim