简体   繁体   中英

EXCEPTION_ACCESS_VIOLATION in Java

I may have come across a weird bug in Java. When I'm running the following code, I get "EXCEPTION_ACCESS_VIOLATION" exception.

I know the code doesn't make sense (in terms of logic) because it's a subset of the code I originally wrote. If I remove several lines the bug disappear.

Can anyone figure out what's the cause of this bug?

public static void main(String[] args) {
    for (int i=0; i < 4000; i++) {
        System.out.println("item " + i);
        test1();
    }

    //runBatch();   
    System.out.println("Done! bye bye..");
}

public static int test1() {
    int     count;
    int     allMiddleCount;
    int[]   b = new int[0];

    allMiddleCount  = 0;
    for (int i = 1; i < 64; i++)
    {
        // evaluating the size of the subset
        count = 0;
        for (int j = 0; j < 6; j++)
            count++;

        allMiddleCount++;
    }

    for (int i=0; i < allMiddleCount; i++) {

    }

    return 0;
}

Can anyone figure out whats the cause of this bug?

If the process is dying rather than it being a normal Java exception, it's basically a JVM bug. You haven't said which platform you're on or which version you're using, but try updating to a later version.

谷歌搜索EXCEPTION_ACCESS_VIOLATION我在 Oracle 站点上发现该 JVM 存在一些仍在调查中的错误

I had this exception while using java to run some specific dlls in my project and it was solved after some months investigating all of our environment, If anyone still needs it here is the link. EXCEPTION_ACCESS_VIOLATION in Jacob dll using VM in Jenkins pipeline

There we have the description of all the things we have tried and maybe it will be of use. The problem was solved by going back to not only the java version, but the specific build version. (in our case it was java 8 build 141)

I tested your code; works fine.

My guess is, this is caused by hardware or software platform problems.

ok, i can confirm that there is a bug in java. i just got a mail from them confirming a new bug.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7178093 (the site will update in two days..)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM