discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.36k stars 735 forks source link

OpusPacket Decode crash #1664

Closed stealth-program closed 2 years ago

stealth-program commented 3 years ago

My bot crashed when I received opus packet and library started to decode it. It happened only once, the rest of the time jda works perfectly.

JDA version: net.dv8tion:JDA:4.2.1_264

It is extremely rare, so I don't think you can reproduce it. But maybe you can add some sort of opus packet validation?

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f1c7cfdd52e, pid=24375, tid=28131
Command Line: -Dfile.encoding=ISO-8859-1 -Duser.country=US -Duser.language=en -Duser.variant callbot.Main

Host: Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS), 4 cores, 7G, Ubuntu 20.04.2 LTS
Time: Sat Jun  5 18:46:04 2021 UTC elapsed time: 18587.246231 seconds (0d 5h 9m 47s)

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

Current thread (0x00007f1c74161800):  JavaThread "JDA AudioConnection Guild: 828018162201002056 Receiving Thread" daemon [_thread_in_native, id=28131, stack(0x00007f1c7d910000,0x00007f1c7da11000)]

Stack: [0x00007f1c7d910000,0x00007f1c7da11000],  sp=0x00007f1c7da0ccb0,  free space=1011k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [jna11453996084510901946.tmp+0x3052e]  opus_decode+0xde
C  [jna8734453908999305279.tmp+0x12dc6]  ffi_call_unix64+0x4c

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 2739  com.sun.jna.Native.invokeInt(Lcom/sun/jna/Function;JI[Ljava/lang/Object;)I (0 bytes) @ 0x00007f1cd8473939 [0x00007f1cd84738c0+0x0000000000000079]
J 4846 c2 com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;ZI)Ljava/lang/Object; (769 bytes) @ 0x00007f1cd86e4ac4 [0x00007f1cd86e4980+0x0000000000000144]
J 3392 c2 com.sun.jna.Function.invoke(Ljava/lang/reflect/Method;[Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object; (548 bytes) @ 0x00007f1cd854a360 [0x00007f1cd8549a00+0x0000000000000960]
J 4837 c2 com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object; (348 bytes) @ 0x00007f1cd86e0e24 [0x00007f1cd86e0c20+0x0000000000000204]
J 3480 c2 net.dv8tion.jda.api.audio.OpusPacket.decode()[S (75 bytes) @ 0x00007f1cd85693bc [0x00007f1cd8568c40+0x000000000000077c]
J 6186 c2 net.dv8tion.jda.internal.audio.AudioConnection.lambda$setupReceiveThread$3()V (622 bytes) @ 0x00007f1cd87bfd50 [0x00007f1cd87bede0+0x0000000000000f70]
j  net.dv8tion.jda.internal.audio.AudioConnection$$Lambda$228.run()V+4
J 6953 c1 java.lang.Thread.run()V java.base@11.0.11 (17 bytes) @ 0x00007f1cd1dc73a4 [0x00007f1cd1dc7240+0x0000000000000164]
v  ~StubRoutines::call_stub

siginfo: si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x00007f1c7da11000
DV8FromTheWorld commented 2 years ago

There has been no additional information for months. Closing this due to being stale.

Leximon commented 3 months ago

Same here. This happens occasionally every few weeks which is very problematic for my voice based bot.

Here's a crash report that should provide some more information: hs_err_pid1.log

It's not an ordinary crash so I have no clue what the cause of this is. I didn't manage to reproduce it. Any help is really REALLY appreciated (my users keep asking why the bot is occasionally offline ;-;)

The source code of the bot can be found here. The bot also uses a slightly modified version of the JDA for the its functionality. Here's the last commit when the bot crashed.