Fatal Java + Arduino Crash

So I’m currently attempting to use Arduino with Java in order to utilize Java features which Arduino normally can’t. I was following the instructions outlined in this guide, which was perfectly fine up until I ran the example code that they had provided.

The first issue I encountered was this line from the initialize() method:

Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

The getPortIdentifiers() method would return an empty array, which would leave the portId variable as null, preventing the actual Arduino part of the code to start. I fixed this issue by placing the line

System.setProperty(“gnu.io.rxtx.SerialPorts”, “/dev/ttyACM0”);

at the beginning of the initialize() method, even though the guide had specified that it was exclusive to the Raspberry Pi.

This allowed the getPortIdentifiers() method to return an array of port identifiers and enter the while loop.

After the program had successfully entered the while loop and found the correct port ID, the program crashed and gave me a fatal JRE error.

Here’s the full output:

Experimental:  JNI_OnLoad called.
Stable Library
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
RXTX Warning:  Removing stale lock file. /var/lock/LCK..ttyACM0

portName: /dev/tty.usbserial-A9007UX1
currPortId: /dev/ttyACM0

portName: /dev/ttyACM0
currPortId: /dev/ttyACM0
# A fatal error has been detected by the Java Runtime Environment:
#  SIGSEGV (0xb) at pc=0x00007fca940c9462, pid=2716, tid=140507439167232
# JRE version: Java(TM) SE Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.91-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [librxtxSerial.so+0x6462]  read_byte_array+0x52
# Core dump written. Default location: /home/oleg/Documents/Scripts/Java/Arduino/core or core.2716
# An error report file with more information is saved as:
# /home/oleg/Documents/Scripts/Java/Arduino/hs_err_pid2716.log
# 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.
Aborted (core dumped)

I’ve attempted to research the issue though the only solution I was able to find that had worked for someone else was to update my microcode.

I am running Debian Jessie 8.5, and followed the instructions on this wiki page regarding Microcode on Debian Linux.

Below, I’ve attached a screenfetch printout as well as the error log mentioned in the SerialTest output.

         _,met$$$gg.           oleg@NOT-A-COMPUTER
      ,g$$$$$$$$P.        OS: Debian 8.5 jessie
    ,g$P""       """Y$.".      Kernel: x86_64 Linux 3.16.0-4-amd64
   ,$P'              `$$.      Uptime: 5d 5h 19m
  ',$P       ,ggs.     `$b:    Packages: 2842
  `d$'     ,$P"'   .    $$     Shell: bash 4.3.30
   $P      d

hs_err_pid2716.txt (31.5 KB)     ,    P     Resolution: 1920x1080   :      .   -    ,d’     DE: Cinnamon 2.2.16
  $;      Y$b._   ,d$P’      WM: Muffin
  Y$.    .“Y$$P”’          WM Theme: Eleganse (Adwaita)
  $b      "-.__               GTK Theme: Adwaita [GTK2], Adwaita [GTK3]    Y$                         Icon Theme: gnome
    Y$.                       Font: Sans 9       $b.                     CPU: Intel Core i5-2500K CPU @ 3.7GHz
        Y$b.                  GPU: GeForce GTX 285            "Y$b.
             RAM: 3897MB / 7958MB

[hs_err_pid2716.txt|attachment](upload://dylnRmvxOur9cVPLXXODEQalW7F.txt) (31.5 KB)

I was able to resolve the issue, as it turns out that the file librtrxSerial.so file that this article directed me to did not work with my Architecture, and I instead found a download for the correct file here.

Thanks for all the help guys, I really appreciate it!