United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7172708 32/64 bit type issues on Windows after Mac OS X port
7172708 : 32/64 bit type issues on Windows after Mac OS X port

Details
Type:
Bug
Submit Date:
2012-05-30
Status:
Closed
Updated Date:
2012-11-07
Project Name:
JDK
Resolved Date:
2012-06-15
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7u4
Fixed Versions:
hs23.2

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
Reported by Chris Dennis on the jdk7u mailing list

"I believe that when the Mac OS X support was merged in to the jdk7u-dev forest that a mistake was made regarding Visual Studio's lack of inttypes.h.  The symptom of this bug can be seen in the following output:

$ java -showversion -d64 -XX:MaxDirectMemorySize=4g OffHeapAllocationTest
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)

Command Line: [-XX:MaxDirectMemorySize=4g]
sun.misc.VM.maxDirectMemory() = 0
java.nio.Bits.maxMemory = 0

Experimenting with different MaxDirectMemorySize values clearly shows this to be a 32-bit wrap-around issue.  When Mac OS X support was merged in, the INTX_FORMAT which is used to write the MaxDirectMemorySize global in to the system properties was modified to use PRIdPTR from inttypes.h.  As Visual Studio lacks inttypes.h, definitions for this (and the other associated format specifiers) were added to globalDefinitions_visCPP.hpp.  However the definitions added are only correct for a 32-bit system.  I believe the following changeset corrects that error (no Windows access prevents me from verifying this fix however)."

Reproducer

public class TestMaxDirectMemory {

   public static void main(String[] args) {
	System.out.println(sun.misc.VM.maxDirectMemory());
   }
}

When run with -XX:MaxDirectMemorySize=4g on a 64bit Windows 1.7.0_04 VM it will print 0 since the high 32bits will get dropped.

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/40b4aaf010e4
                                     
2012-06-29
EVALUATION

<moved to hs24 subCR>
                                     
2012-06-14
EVALUATION

http://hg.openjdk.java.net/hsx/hsx23.2/hotspot/rev/7871a1b632cb
                                     
2012-06-13
EVALUATION

See suggested fix.
                                     
2012-06-08
SUGGESTED FIX

diff -r bca9e76ea254 src/share/vm/utilities/globalDefinitions_visCPP.hpp
--- a/src/share/vm/utilities/globalDefinitions_visCPP.hpp	Tue Mar 20 10:17:41 2012 -0700
+++ b/src/share/vm/utilities/globalDefinitions_visCPP.hpp	Tue May 22 17:24:57 2012 -0400
@@ -220,9 +220,15 @@
#define PRIu64       "I64u"
#define PRIx64       "I64x"

+#ifdef _LP64
+#define PRIdPTR       "I64d"
+#define PRIuPTR       "I64u"
+#define PRIxPTR       "I64x"
+#else
#define PRIdPTR       "d"
#define PRIuPTR       "u"
#define PRIxPTR       "x"
+#endif

#define offset_of(klass,field) offsetof(klass,field)
                                     
2012-05-30



Hardware and Software, Engineered to Work Together