NeuronRobotics / nrjavaserial

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.
Other
344 stars 142 forks source link

JVM hangs at shutdown #228

Open neeme-praks-sympower opened 2 years ago

neeme-praks-sympower commented 2 years ago

Machine: ARMv5 machine (uname tells armv5tejl). JVM:

java version "1.8.0_211"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_211-b12, profile compact3, headless)
Java HotSpot(TM) Embedded Client VM (build 25.211-b12, mixed mode)

Versions affected: com.neuronrobotics:nrjavaserial:5.2.1

Steps to reproduce:

  1. Open serial port
  2. Communicate via the serial port
  3. Close the serial port
  4. List available ports
  5. Exit JVM

(just listing available ports does not trigger this bug)

Expected result vs actual result:

It seems that the RXTXPortMonitor thread is not stopped?

Thread dump of the hanging JVM:

Full thread dump Java HotSpot(TM) Embedded Client VM (25.211-b12 mixed mode):

"DestroyJavaVM" #8 prio=5 os_prio=0 tid=0xb6607400 nid=0x985 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"RXTXPortMonitor(/dev/ttyS6)" #7 prio=5 os_prio=0 tid=0xb66aec00 nid=0x995 runnable [0xafefe000]
   java.lang.Thread.State: RUNNABLE
    at gnu.io.RXTXPort.eventLoop(Native Method)
    at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:108)

"Service Thread" #6 daemon prio=9 os_prio=0 tid=0xb667b400 nid=0x98b runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0xb6679000 nid=0x98a waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0xb6677800 nid=0x989 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0xb665c800 nid=0x988 in Object.wait() [0xb01fe000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0xb09f6230> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
    - locked <0xb09f6230> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0xb665ac00 nid=0x987 in Object.wait() [0xb4471000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0xb09f63d0> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
    - locked <0xb09f63d0> (a java.lang.ref.Reference$Lock)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

"VM Thread" os_prio=0 tid=0xb6655400 nid=0x986 runnable

"VM Periodic Task Thread" os_prio=0 tid=0xb667c800 nid=0x98c waiting on condition

JNI global references: 5

Heap
 def new generation   total 1920K, used 852K [0xb0800000, 0xb0a00000, 0xb1c00000)
  eden space 1792K,  40% used [0xb0800000, 0xb08b50f8, 0xb09c0000)
  from space 128K, 100% used [0xb09e0000, 0xb0a00000, 0xb0a00000)
  to   space 128K,   0% used [0xb09c0000, 0xb09c0000, 0xb09e0000)
 tenured generation   total 4096K, used 632K [0xb1c00000, 0xb2000000, 0xb4400000)
   the space 4096K,  15% used [0xb1c00000, 0xb1c9e2a0, 0xb1c9e400, 0xb2000000)
 Metaspace       used 2537K, capacity 2568K, committed 2584K, reserved 4400K