0

I'm using MATLAB Engine API for Java, so far basics such as eval and feval functions work without a problem. I even drew an histogram with those. But PutVariable method causes me to have "EXCEPTION_ACCESS_VIOLATION".

Code is:

package connecter;

import java.util.*;  
import java.util.concurrent.ExecutionException;

import com.mathworks.engine.*;

public class MainClass {

    public static void main(String[] args) throws IllegalArgumentException, IllegalStateException, InterruptedException, MatlabExecutionException, MatlabSyntaxException, ExecutionException {

        MatlabEngine matEng = MatlabEngine.startMatlab();
        matEng.putVariable("x", 3.0);
}

Console gives me the following:

# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000001b224d20b95, pid=1904, tid=8768
#
# JRE version: Java(TM) SE Runtime Environment (12.0.2+10) (build 12.0.2+10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (12.0.2+10, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# v  ~StubRoutines::atomic_add_long
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# [Filepath]\hs_err_pid1904.log
Could not load hsdis-amd64.dll; library not loadable; PrintAssembly is disabled
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

So far I've searched through countless threads but nothing has worked so far. I'm using JavaSE-12 and MATLAB is R2019b.

3
  • 2
    Wow, that actually looks like a bug in the JDK! Try a different version of the JDK. MathWorks tends to stick with much older versions of Java, so they may not have tested it extensively with newer versions of Java. Also check the Matlab documentation to make sure the version of Java you're using is supported with the Matlab Java Engine. Commented Dec 8, 2019 at 20:13
  • 2
    Similar issue, maybe it is your AV: superuser.com/questions/683895/… Other than that, I would contact the Mathworks support about this, and forward the hs_err_pid1904.log to them. Commented Dec 8, 2019 at 20:42
  • 1
    Yep. Something in your Matlab or JDK here is FUBARed. This isn't something you can directly fix on your own. Time to call support for one or both of them. Commented Dec 9, 2019 at 20:10

1 Answer 1

1

You're doing it right. This is a bug in Matlab, the JDK, or both. Not much you can do here. Contact support for MathWorks and your JDK vendor and let them know what happened, and talk to your IT department to see if you have a weird machine configuration that might be messing them up.

And try running against a different JDK, like a much lower major version such as JDK 8. Matlab uses old JDK versions, so it's more likely to be tested and work against them.

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

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.