Subject: Re: 32 bit linux java solution?
To: Arto Huusko <>
From: Nicolas Joly <>
List: port-amd64
Date: 11/22/2007 21:24:29
On Wed, Nov 21, 2007 at 12:46:53AM +0200, Arto Huusko wrote:
> I think I have found the reason why 32 bit linux java eventually
> ends up in the state where one thread keeps faulting, and another
> thread keeps on calling sched_yield. (BTW, 64 bit java is not
> functional even on AMD processors in -current, but that's beside
> the point here...)
> It has to do with some JVM feature called safepointing, which is
> implemented by a thread manipulating protection of one page,
> and then yielding until other threads notice the situation
> by getting SIGSEGV, and doing whatever they need to do.
> On NetBSD, the thread getting SIGSEGV doesn't notice that the
> signal was received due to safepointing (and apparently ends up
> restarting the instruction over and over again), because
>  - for some reason JVM inspects the fault address from cr2 field
>    of mcontext of ucontext (instead of si_addr of sigcontext)
>    see JVM_handle_linux_signal in
> 	hotspot/src/os_cpu/linux_i486/os_linux_i486.cpp
>  - NetBSD linux32 emul does not set this field
>    see linux32_save_sigcontext in
> 	sys/compat/linux32/arch/amd64/linux32_machdep.c
>    in revision 1.12, on line 389:
> 	/* sc->sc_cr2 = l->l_addr->u_pcb.pcb_cr2; */ /* XXX */
> I unfortunately have no idea where a suitable value for cr2 is
> available at that point...

Nice catch !

Not sure about your ant problem, but i can say that christos patch
seems to fix sun15-javac under compat linux32 which was crashing
previously with the simple following code :

njoly@lanfeust [linux/java]> cat
class HelloWorld {
        public static void main (String args[]) {
                System.out.println("Hello World!");

njoly@lanfeust [linux/java]> /usr/pkg/bin/sun15-javac
# An unexpected error has been detected by HotSpot Virtual Machine:
#  SIGSEGV (0xb) at pc=0xf6eea9d4, pid=3186, tid=16384
# Java VM: Java HotSpot(TM) Server VM (1.5.0_12-b04 mixed mode)
# Problematic frame:
# J;)Lcom/sun/tools/javac/jvm/ClassReader$Archive;
# An error report file with more information is saved as hs_err_pid3186.log
# If you would like to submit a bug report, please visit:
[1]   Abort trap (core dumped) /usr/pkg/java/su...
njoly@lanfeust [linux/java]> echo $?

It now compiles and runs ok.

njoly@lanfeust [linux/java]> /usr/pkg/bin/sun15-javac
njoly@lanfeust [linux/java]> echo $?
njoly@lanfeust [linux/java]> /usr/pkg/bin/sun15-java HelloWorld
Hello World!

Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.