1

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;
}
8
  • 2
    What line? Where? Do you have a StackTrace? Commented Jun 19, 2012 at 13:32
  • What line of code throws the exception? Commented Jun 19, 2012 at 13:32
  • 2
    Just tested the code you posted and it works fine on my machine (1.7.0_03). What version of Java are you using? Commented Jun 19, 2012 at 13:32
  • 2
    Works on 1.6.0_31 but does indeed fail with 1.7.0_05 Commented Jun 19, 2012 at 13:33
  • 1
    If you manage to reduce the code leading to the crash, this could be interesting. Commented Jun 19, 2012 at 13:37

5 Answers 5

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

its on windows64 bit with either jave 1.6 or 1.7. i tested it on two different computers (With the same spec) and got the same results
3

Googling for EXCEPTION_ACCESS_VIOLATION lands me on the Oracle site that there are some bugs with the that JVM that are still under investigation

Comments

1

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)

Comments

0

I tested your code; works fine.

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

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.