0

I am experiencing JVM crash for following simple code..

import sun.misc.Unsafe;
public class TestProgram {
       static Unsafe unsafe = Util.getUnsafe();
       public static void main(String args[]){
         long iBlockSize = 3;
         long address = unsafe.allocateMemory((iBlockSize*1024));
         short val = -1;
         byte val2 = -1; 
         long endAddress = address + (iBlockSize*1024);
         for(long lStartAdd = address; lStartAdd < endAddress; 
                                       lStartAdd += iBlockSize)
         {           
             unsafe.putShort(lStartAdd, val);
             unsafe.putByte(lStartAdd+2, val2);
         }
         unsafe.freeMemory(address);
         System.out.println("Completed sucessfully ...");
       }
}

Error is:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGBUS (0xa) at pc=0xffffffff7e178cf0, pid=22073, tid=2
#
# JRE version: 6.0_27-b07
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.2-b06 mixed mode solaris-sparc compressed oops)
# Problematic frame:
# V [libjvm.so+0x978cf0] Unsafe_SetNativeShort+0x138
#
# An error report file with more information is saved as:
# /home/eQubeQa/Core/DC_Testing/SK_solarisBug/hs_err_pid22073.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

Where as if I change the iBlockSize to 4 or 8 or 16 etc. it works.
I tried this on both Sun_jdk and JRockit.
Following are the some important system properties,

java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0_27-b07
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.specification.version=1.6
java.vendor=Sun Microsystems Inc.
java.version=1.6.0_27
java.vm.info=mixed mode
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.version=1.0
java.vm.vendor=Sun Microsystems Inc.
java.vm.version=20.2-b06
os.arch=sparcv9
os.name=SunOS
os.version=5.10
sun.arch.data.model=64
sun.cpu.endian=big
sun.management.compiler=HotSpot 64-Bit Tiered Compilers

I am getting this only on solaris, It worked on Windows,Linux,AIX etc.

What could be the problem(code/jdk_issue/?)?

pradipmw
  • 191
  • 2
  • 11
  • Please print out `lStartAdd` and `address` for debugging. The segmentation fault might be related to weird memory alignment in Solaris - just a guess, sorry I don't have experience programming in Solaris. –  Mar 07 '14 at 08:33
  • As this is memory alignment issue(filed [bug](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8021574) : [8021574](http://bugs.java.com/bugdatabase/home.do)). We handled this by writing on aligned address location. – pradipmw Apr 28 '14 at 05:55

0 Answers0