segmentation fault - Java fatal error SIGSEGV -


i getting error message java compiler don't understand. i've tested code on osx 10.6, 10.9, , ubuntu 14.04, both java 6 , 7. when run eclipse debugger or interpreter (using -xint option), runs fine. otherwise, following messages:

java 1.6:

invalid memory access of location 0x8 rip=0x1024e9660 

java 1.7:

# # fatal error has been detected java runtime environment: # #  sigsegv (0xb) @ pc=0x000000010f7a8262, pid=20344, tid=18179 # # jre version: java(tm) se runtime environment (7.0_60-b19) (build 1.7.0_60-b19) # java vm: java hotspot(tm) 64-bit server vm (24.60-b09 mixed mode bsd-amd64 compressed oops) # problematic frame: # v  [libjvm.dylib+0x3a8262]  phaseidealloop::idom_no_update(node*) const+0x12 # # failed write core dump. core dumps have been disabled. enable core dumping, try "ulimit -c unlimited" before starting java again # # if submit bug report, please visit: #   http://bugreport.sun.com/bugreport/crash.jsp # 

there's more error output java 7 (that saved file) unfortunately can't fit in character limit of post. need run code couple of times error come up, appears more not.

my test case involves cacheing computations in logarithmic scale. specifically, given log(x),log(y),..., have small class computes log(x+y+...). , cache result in hashmap.

strangely, changing loop indices seems make problem go away. in particular, if replace

for (int z = 1; z < x+1; z++) {     double logsummand = math.log(z + x + y);     toreturn.addlogsummand(logsummand); } 

with

for (int z = 0; z < x; z++) {     double logsummand = math.log(1 + z + x + y);     toreturn.addlogsummand(logsummand); } 

then don't error message , program runs fine.

my minimal example below:

import java.util.arrays; import java.util.hashmap; import java.util.list; import java.util.map; public class testlogsum {     public static void main(string[] args) {          (int = 0; < 6; i++) {             (int n = 2; n < 30; n++) {                 (int j = 1; j <= n; j++) {                     (int k = 1; k <= j; k++) {                         system.out.println(computesum(k, j));                                            }                 }             }         }     }      private static map<list<integer>, double> cache = new hashmap<list<integer>, double>();     public static double computesum(int x, int y) {              list<integer> key = arrays.aslist(new integer[] {x, y});          if (!cache.containskey(key)) {              // explicitly creating/updating double[] array, instead of using logsumarray wrapper object, prevent error             logsumarray toreturn = new logsumarray(x);              // changing loop indices prevent error             // in particular, for(z=0; z<x-1; z++), , using z+1 in place of z, not produce error //          (int z = 0; z < x; z++) { //              double logsummand = math.log(1 + z + x + y);             (int z = 1; z < x+1; z++) {                 double logsummand = math.log(z + x + y);                 toreturn.addlogsummand(logsummand);             }              // returning value here without cacheing prevent segfault             cache.put(key, toreturn.retrievelogsum());         }         return cache.get(key);     }      /*      * given bunch of logarithms log(x),log(y),log(z),...      * class used compute log of sum, log(x+y+z+...)      */     private static class logsumarray {               private double[] logsummandarray;         private int currsize;          private double maxlogsummand;          public logsumarray(int maxentries) {             this.logsummandarray = new double[maxentries];              this.currsize = 0;             this.maxlogsummand = double.negative_infinity;         }          public void addlogsummand(double logsummand) {             logsummandarray[currsize] = logsummand;             currsize++;             // removing line prevent error             maxlogsummand = math.max(maxlogsummand, logsummand);         }          public double retrievelogsum() {             if (maxlogsummand == double.negative_infinity) return double.negative_infinity;              assert currsize <= logsummandarray.length;              double factorsum = 0;             (int = 0; < currsize; i++) {                 factorsum += math.exp(logsummandarray[i] - maxlogsummand);             }              return math.log(factorsum) + maxlogsummand;         }     } } 

so after reading comments, seems bug in jvm needs reported oracle. so, have gone ahead , filed bug report oracle. i'll post updates when hear them.

thanks tried code , found breaks on machines well.

if there ability/inclination figure out code in compiler causing error, awesome hear :)

update: oracle responded yesterday, said prepared fix bug , asked include code regression test :) didn't explain problem was, beyond saying in hotspot jit, did send me link changes made, in case interested: http://cr.openjdk.java.net/~kvn/8046516/webrev/


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -