Fwd: Report a bug in HotSpot

Krystal Mo krystal.mo at oracle.com
Mon Nov 26 10:29:56 PST 2012

Hi all,

Xi Yang has reported a bug in HotSpot's interpreter that it doesn't 
empty the FPU stack on return from JNI calls. His mail is included below.

e.g. If a native function called via JNI is using MMX registers without 
emptying the FPU stack before returning, then after returning to Java 
the FPU stack will be in a bad state.

The test case Xi gave is demonstrated here on JDK7u9, x86: 
Running the example with -XX:+VerifyFPU shows what's going on.

This test case shows the bug affecting 32-bit x86 version of HotSpot's 

Not really familiar with how to file a bug on JBS yet, I'll file a bug 
to track this after I learn how to do it.


-------- Original Message --------
Subject: 	Fwd: Report a bug in HotSpot
Date: 	Tue, 27 Nov 2012 02:02:59 +0800
From: 	Krystal Mok <rednaxelafx at gmail.com>
To: 	Krystal Mo <krystal.mo at oracle.com>

---------- Forwarded message ----------
From: Xi Yang <hiyangxi at gmail.com>
Date: Tue, Nov 20, 2012 at 1:44 PM
Subject: Report a bug in HotSpot
To: Krystal Mok <rednaxelafx at gmail.com>


It looks like HotSpot does not do "emms" after backing from JNI. Here
is the code to show the bug. Would you like to try the newest version?

class Hello {
     private static native void abc();
     public static void main(String[] args) {
       System.out.println("I am main");
         long a = 100;
         double b = (double)a;
         System.out.println("Double a is " + b);

#include <jni.h>
#include <stdio.h>

Java_Hello_abc(JNIEnv *env, jclass cls)
   printf("I mmmmmmmmmmmmmmmmmmmmmmmmm java Helo world\n");
   unsigned int dummy;
   asm volatile("movd %%mm0, %0\n":"=r"(dummy));
   printf("dummy is %x\n", dummy);

gcc -m32 -shared   ./Hello.c -o ./libHello.so

/opt/jdk1.7.0/bin/java -Djava.library.path=. Hello
I am main
I mmmmmmmmmmmmmmmmmmmmmmmmm java Helo world
dummy is 0
Double a is NaN

$ /opt/jdk1.7.0/bin/java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b93)
Java HotSpot(TM) Server VM (build 18.0-b04, mixed mode)

More information about the hotspot-dev mailing list