Java RXTX EXCEPTION_ACCESS_VIOLATION EXCEPTION_ACCESS_VIOLATION (0xc0000005) with Arduino in Intellij

-1

I am using an Arduino Micro and want to read serial data from my Java IDE. I have installed all required softwares/libs for intellij to test this functionality. The java code is from Arduino RXTX page.

Not matter what I do I always get the following error included in the log file attached

Arduino code :

void setup(){


Serial.begin(9600);

}

void loop(){
  Serial.println("Hello world");
  delay(1000);
}

Java Code:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.util.Enumeration;


public class SerialTest implements SerialPortEventListener {
    SerialPort serialPort;
    /** The port we're normally going to use. */
    private static final String PORT_NAMES[] = {
            "/dev/tty.usbserial-A9007UX1", // Mac OS X
            "/dev/ttyACM0", // Raspberry Pi
            "/dev/ttyUSB0", // Linux
            "COM10", // Windows
    };
    /**
     * A BufferedReader which will be fed by a InputStreamReader
     * converting the bytes into characters
     * making the displayed results codepage independent
     */
    private BufferedReader input;
    /** The output stream to the port */
    private OutputStream output;
    /** Milliseconds to block while waiting for port open */
    private static final int TIME_OUT = 2000;
    /** Default bits per second for COM port. */
    private static final int DATA_RATE = 9600;

    public void initialize() {
        // the next line is for Raspberry Pi and
        // gets us into the while loop and was suggested here was suggested http://www.raspberrypi.org/phpBB3/viewtopic.php?f=81&t=32186
        //System.setProperty("gnu.io.rxtx.SerialPorts", "/dev/ttyACM0");

        CommPortIdentifier portId = null;
        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

        //First, Find an instance of serial port as set in PORT_NAMES.
        while (portEnum.hasMoreElements()) {
            CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
            for (String portName : PORT_NAMES) {
                if (currPortId.getName().equals(portName)) {
                    portId = currPortId;
                    break;
                }
            }
        }
        if (portId == null) {
            System.out.println("Could not find COM port.");
            return;
        }

        try {
            // open serial port, and use class name for the appName.
            serialPort = (SerialPort) portId.open(this.getClass().getName(),
                    TIME_OUT);

            // set port parameters
            serialPort.setSerialPortParams(DATA_RATE,
                    SerialPort.DATABITS_8,
                    SerialPort.STOPBITS_1,
                    SerialPort.PARITY_NONE);

            // open the streams
            input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
            output = serialPort.getOutputStream();

            // add event listeners
            serialPort.addEventListener(this);
            serialPort.notifyOnDataAvailable(true);
        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }

    /**
     * This should be called when you stop using the port.
     * This will prevent port locking on platforms like Linux.
     */
    public synchronized void close() {
        if (serialPort != null) {
            serialPort.removeEventListener();
            serialPort.close();
        }
    }

    /**
     * Handle an event on the serial port. Read the data and print it.
     */
    public synchronized void serialEvent(SerialPortEvent oEvent) {
        if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
            try {
                String inputLine=input.readLine();
                System.out.println(inputLine);
            } catch (Exception e) {
                System.err.println(e.toString());
            }
        }
        // Ignore all the other eventTypes, but you should consider the other ones.
    }

    public static void main(String[] args) throws Exception {
        SerialTest main = new SerialTest();
        main.initialize();
        Thread t=new Thread() {
            public void run() {
                //the following line will keep this app alive for 1000 seconds,
                //waiting for events to occur and responding to them (printing incoming messages to console).
                try {Thread.sleep(1000000);} catch (InterruptedException ie) {}
            }
        };
        t.start();
        System.out.println("Started");
    }
}

And finally the log file produced by Intellij IDE:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180005b00, pid=14804, tid=8080
#
# JRE version: Java(TM) SE Runtime Environment (10.0.2+13) (build 10.0.2+13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0.2+13, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  [rxtxSerial.dll+0x5b00]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  S U M M A R Y ------------

Command Line: -Djava.library.path=C:\Program Files\Java\jre-10.0.2\lib -javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2\lib\idea_rt.jar=52766:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2\bin -Dfile.encoding=UTF-8 SerialPortHandler

Host: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz, 4 cores, 7G,  Windows 8.1 , 64 bit Build 9600 (6.3.9600.17415)
Time: Sun Aug 12 23:41:28 2018 Mitteleuropäische Sommerzeit elapsed time: 1 seconds (0d 0h 0m 1s)

---------------  T H R E A D  ---------------

Current thread (0x00000016b48a3800):  JavaThread "Thread-0" [_thread_in_native, id=8080, stack(0x00000016b5c80000,0x00000016b5d80000)]

Stack: [0x00000016b5c80000,0x00000016b5d80000],  sp=0x00000016b5d7e450,  free space=1017k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [rxtxSerial.dll+0x5b00]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  gnu.io.RXTXPort.readArray([BII)I+0
j  gnu.io.RXTXPort$SerialInputStream.read([BII)I+212
j  sun.nio.cs.StreamDecoder.readBytes()I+135 java.base@10.0.2
j  sun.nio.cs.StreamDecoder.implRead([CII)I+112 java.base@10.0.2
j  sun.nio.cs.StreamDecoder.read([CII)I+180 java.base@10.0.2
j  java.io.InputStreamReader.read([CII)I+7 java.base@10.0.2
j  java.io.BufferedReader.fill()V+145 java.base@10.0.2
j  java.io.BufferedReader.readLine(Z)Ljava/lang/String;+44 java.base@10.0.2
j  java.io.BufferedReader.readLine()Ljava/lang/String;+2 java.base@10.0.2
j  SerialPortHandler.serialEvent(Lgnu/io/SerialPortEvent;)V+12
j  gnu.io.RXTXPort.sendEvent(IZ)Z+382
v  ~StubRoutines::call_stub
j  gnu.io.RXTXPort.eventLoop()V+0
j  gnu.io.RXTXPort$MonitorThread.run()V+12
v  ~StubRoutines::call_stub

siginfo: EXCEPTION_ACCESS_VIOLATION (0xc0000005), reading address 0xffffffffb5d7f218


Register to memory mapping:

RIP=0x0000000180005b00 rxtxSerial.dll
RAX=0x0000000000000001 is an unknown value
RBX=0x0000000000000000 is an unknown value
RCX=0x000000018001d4d5 rxtxSerial.dll
RDX=0xfffffffffffff665 is an unknown value
RSP=0x00000016b5d7e450 is pointing into the stack for thread: 0x00000016b48a3800
RBP=
[error occurred during error reporting (printing register info), id 0xc0000005]

Registers:
RAX=0x0000000000000001, RBX=0x0000000000000000, RCX=0x000000018001d4d5, RDX=0xfffffffffffff665
RSP=0x00000016b5d7e450, RBP=0x00000000ffffffff, RSI=0x0000000000000000, RDI=0x00000016b48a3a70
R8 =0x0000000000000002, R9 =0xfffffffffffff63c, R10=0x0000000000000006, R11=0x8101010101010100
R12=0xffffffffb5d7f210, R13=0x000000000000000d, R14=0x00000016b5d7e640, R15=0x0000000000000000
RIP=0x0000000180005b00, EFLAGS=0x0000000000010202

Top of Stack: (sp=0x00000016b5d7e450)
0x00000016b5d7e450:   0000000000000000 0000000000000000
0x00000016b5d7e460:   00000016b5d7e648 0000000000000000
0x00000016b5d7e470:   0000000000000000 00000016b5d7e640
0x00000016b5d7e480:   00000016b3deeca8 0000000000000001
0x00000016b5d7e490:   00000016b48a3a70 000000000000000d
0x00000016b5d7e4a0:   ffffffffffffffff 0000000180006211
0x00000016b5d7e4b0:   00000016b48eead0 0000000000000000
0x00000016b5d7e4c0:   ffffffff00000001 00000016b48eead0
0x00000016b5d7e4d0:   000000160000000d 00000000ffffffff
0x00000016b5d7e4e0:   00000016b5d7e648 00000016b3deecb0
0x00000016b5d7e4f0:   00000016b3deecb0 00000016b4f386f0
0x00000016b5d7e500:   00000016b5d7ee98 00000000639846e3
0x00000016b5d7e510:   00000016b48a3800 000000010007c910
0x00000016b5d7e520:   00000016b4f386f0 0000329a99eaa3e1
0x00000016b5d7e530:   00000016b3deecb0 00000016b3deeca8
0x00000016b5d7e540:   00000016b48a3800 00000016b5d7e648 

Instructions: (pc=0x0000000180005b00)
0x0000000180005ae0:   15 23 7a 01 00 48 8d 48 60 e8 3a 5d 00 00 4c 8b
0x0000000180005af0:   e5 8b ac 24 88 00 00 00 44 8b ac 24 80 00 00 00
0x0000000180005b00:   45 8b 74 24 08 41 89 5c 24 08 41 8b fd 85 ed 78
0x0000000180005b10:   09 ff 15 e9 14 01 00 44 8b f8 45 85 ed 7e 4a 90 



---------------  P R O C E S S  ---------------

Threads class SMR info:
_java_thread_list=0x00000016b45aa740, length=14, elements={
0x00000016b33b4800, 0x00000016b33c1800, 0x00000016b340a800, 0x00000016b340b800,
0x00000016b340f800, 0x00000016b4578800, 0x00000016b4586000, 0x00000016b45a4800,
0x00000016b4f50000, 0x00000016b48c7000, 0x00000016b48c7800, 0x00000016b48a3800,
0x00000016b4f35000, 0x000000168f96d800
}

Java Threads: ( => current thread )
  0x00000016b33b4800 JavaThread "Reference Handler" daemon [_thread_blocked, id=1712, stack(0x00000016b4220000,0x00000016b4320000)]
  0x00000016b33c1800 JavaThread "Finalizer" daemon [_thread_blocked, id=14476, stack(0x00000016b4320000,0x00000016b4420000)]
  0x00000016b340a800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=10764, stack(0x00000016b4930000,0x00000016b4a30000)]
  0x00000016b340b800 JavaThread "Attach Listener" daemon [_thread_blocked, id=10520, stack(0x00000016b4a30000,0x00000016b4b30000)]
  0x00000016b340f800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=3248, stack(0x00000016b4b30000,0x00000016b4c30000)]
  0x00000016b4578800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=14748, stack(0x00000016b4c30000,0x00000016b4d30000)]
  0x00000016b4586000 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=15184, stack(0x00000016b4d30000,0x00000016b4e30000)]
  0x00000016b45a4800 JavaThread "Sweeper thread" daemon [_thread_blocked, id=14420, stack(0x00000016b4e30000,0x00000016b4f30000)]
  0x00000016b4f50000 JavaThread "Common-Cleaner" daemon [_thread_blocked, id=3092, stack(0x00000016b5730000,0x00000016b5830000)]
  0x00000016b48c7000 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=13244, stack(0x00000016b5830000,0x00000016b5930000)]
  0x00000016b48c7800 JavaThread "Service Thread" daemon [_thread_blocked, id=10940, stack(0x00000016b5930000,0x00000016b5a30000)]
=>0x00000016b48a3800 JavaThread "Thread-0" [_thread_in_native, id=8080, stack(0x00000016b5c80000,0x00000016b5d80000)]
  0x00000016b4f35000 JavaThread "Thread-1" [_thread_blocked, id=4024, stack(0x00000016b5d80000,0x00000016b5e80000)]
  0x000000168f96d800 JavaThread "DestroyJavaVM" [_thread_blocked, id=14688, stack(0x0000001691170000,0x0000001691270000)]

I couldnt include complete complete log file due to character limitations. Does anyone have any Idea what I am doing wrong?

java
intellij-idea
arduino
rxtx
asked on Stack Overflow Aug 13, 2018 by Locke

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0