webrtc-java icon indicating copy to clipboard operation
webrtc-java copied to clipboard

Native crash (SIGSEGV) on process shutdown

Open KF-Miyata opened this issue 5 months ago • 6 comments

Describe the bug Runtime behavior is fine during execution, but a native crash occurs on program exit.

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f310ed1610d, pid=252732, tid=0x00007f3140569700
#
# JRE version: OpenJDK Runtime Environment (8.0_432-b06) (build 1.8.0_432-432-b06)
# Java VM: OpenJDK 64-Bit Server VM (25.432-b06 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libwebrtc-java-linux-x86_642121276466645068163.so+0x4d010d]  jni::JavaFactory<webrtc::RtpTransceiverInterface>::~JavaFactory()+0x2d
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/dev/hs_err_pid252732.log

To Reproduce Minimal code:

import dev.onvoid.webrtc.media.audio.AudioProcessing;

public class Repro {
    public static void main(String[] args) {
        AudioProcessing ap = new AudioProcessing();
        ap.dispose();
    }
}

Gradle dependencies:

implementation "dev.onvoid.webrtc:webrtc-java:0.14.0"
implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.14.0", classifier: "linux-x86_64"

Expected behavior Process should exit cleanly with no crash

Desktop (please complete the following information):

  • OS: AlmaLinux 8.10 (Cerulean Leopard)
  • Architecture: x86_64

KF-Miyata avatar Sep 19 '25 01:09 KF-Miyata

Thanks for the report! I see that you are using the OpenJDK Runtime Environment (8.0_432-b06), which is quite outdated.

Unfortunately, I can't reproduce the issue on AlmaLinux 8 using newer JDKs. I will try it with JDK 8 later.

Could you also try to reproduce this behaviour with JDK 17, for example?

devopvoid avatar Sep 19 '25 13:09 devopvoid

Thank you for your reply, and I apologize for the delay. I have tested with JDK 17, and I can confirm that the issue does not occur with that version.

KF-Miyata avatar Sep 24 '25 08:09 KF-Miyata

I'm also seeing SIGSEGV on JVM 25

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fd4b21817e7, pid=178907, tid=179957
#
# JRE version: OpenJDK Runtime Environment Corretto-25.0.0.36.2 (25.0+36) (build 25+36-LTS)
# Java VM: OpenJDK 64-Bit Server VM Corretto-25.0.0.36.2 (25+36-LTS, mixed mode, emulated-client, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libwebrtc-java-linux-x86_649756144665632658865.so+0x84a7e7]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %d %F" (or dumping to /home/kalgecin/***/core.178907)
#
# If you would like to submit a bug report, please visit:
#   https://github.com/corretto/corretto-25/issues/
# 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: -Dvisualvm.id=12399302740675 -Xmx20G -XX:TieredStopAtLevel=1 -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dmanagement.endpoints.jmx.exposure.include=* -javaagent:/home/kalgecin/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/lib/idea_rt.jar=44989 -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 com.****

Host: AMD Ryzen 5 3600 6-Core Processor, 12 cores, 62G, Manjaro Linux
Time: Thu Sep 25 09:43:23 2025 UTC elapsed time: 140.269789 seconds (0d 0h 2m 20s)

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

Current thread (0x00007fd3b0025e10):  JavaThread "Thread-10"        [_thread_in_native, id=179957, stack(0x00007fd440eeb000,0x00007fd4416eb000) (8192K)]

Stack: [0x00007fd440eeb000,0x00007fd4416eb000],  sp=0x00007fd4416e9d90,  free space=8187k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libwebrtc-java-linux-x86_649756144665632658865.so+0x84a7e7]
C  [libwebrtc-java-linux-x86_649756144665632658865.so+0x849ba6]
C  [libwebrtc-java-linux-x86_649756144665632658865.so+0x84b1f9]
C  [libc.so.6+0x969cb]

siginfo: si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x00007fd41d2d88c8

kalgecin avatar Sep 25 '25 08:09 kalgecin

but mine comes from peerConnectionFactory.dispose(). I will try to reproduce with minimal code and probably open a new ticket

kalgecin avatar Sep 26 '25 05:09 kalgecin

Figured out my problem. I was trying to dispose peer connection factory from within PeerConnectionObserver (that was passed into factory.createPeerConnection). Changing the logic around fixed the problem.

kalgecin avatar Sep 26 '25 09:09 kalgecin

Can it be compatible with Java 8?

selfancy avatar Nov 01 '25 10:11 selfancy