Closed DeDiamondPro closed 3 years ago
Hmmm... The problem is that runCallbacks
itself cannot really cause crashes (as it just calls another function).
So the problem is most likely in one of the callbacks that is executed and therefore hard to trace.
I will try to investigate more around the addresses of the stack trace, but it would be really helpful to have a core dump of the crash. I think there is a way of enabling those (see https://stackoverflow.com/questions/18459037/how-to-enable-minidumps-in-java-for-windows). So, it would be nice and super helpful if you could see if the same crash happens again while minidumps are enabled and then send me the produced dump file.
It would also be useful to know which exact version of the library (and your system architecture please) you are using.
Hmmm... The problem is that
runCallbacks
itself cannot really cause crashes (as it just calls another function). So the problem is most likely in one of the callbacks that is executed and therefore hard to trace.I will try to investigate more around the addresses of the stack trace, but it would be really helpful to have a core dump of the crash. I think there is a way of enabling those (see https://stackoverflow.com/questions/18459037/how-to-enable-minidumps-in-java-for-windows). So, it would be nice and super helpful if you could see if the same crash happens again while minidumps are enabled and then send me the produced dump file.
It would also be useful to know which exact version of the library (and your system architecture please) you are using.
Will do but I might not be able to replicate it since it happens kinda randomly
Which version of the library are you using? That latest presumably? It would help a lot to know that, so I know which version I need to debug.
Yes the latest
also my source code is at https://github.com/DeDiamondPro/HyCord/tree/dev I tought that might help
Yes, that should help. I will try to play a bit with the mod to see when it crashes, maybe I will be able to get a coredump.
How often do these crashes happen? Is there anything you suspect might cause them?
I had a look at the source code and I thought that the closing of the Core
might cause some problems if it is currently in a callback or something like that. But that would only be possible if the crashes happen when leaving the server.
So, I have never actually got the crash myself but someone crashed for the reason twice and someone else I was watching a stream of while using the mod just crashed out of nowhere. I have no idea how much it happens but my best guess is after around 2-3 hours of playing (also use a pre-release the other ones didn't use this lib)
I got another a crash with the same code, unsure if it's the same thing but here is the core dumb: https://www.mediafire.com/file/h6zmca1c3dse2ln/hs_err_pid5048.zip/file
Oh, thank you. Do you also have the text crash report for that one?
Yes I do, (not the same crash as the first one looking at this) hs_err_pid5048.log
So, first of all: This crash is even more confusing than the last one, because the native stack only contains a reference to KERNELBASE.dll+0x34b59
which might indicate that the stack was corrupted somewhere.
Second, it looks like this crash was triggered by interacting with the VoiceMenu
GUI, specifically by muting/unmuting yourself. Is that correct? Does the crash every time you do that or also just randomly?
Also, kind of good news: I managed to replicate an error, probably not exactly the one you had, but it's a start.
A lot of Discord calls look Rust-related, so could you please add RUST_BACKTRACE=full
to the environment variables and see if that produces more verbose logs on the next crash?
Yes thats correct this one is produced by voiceMenu, I basically was making a menu for it and then when spamming the button a bit the crash happened, I think (but could be wrong) that this is caused because I’m trying to acces/change something that still has a pending change
Yes, that is quite likely.
What I also just noticed is that both crash reports display EXCEPTION_UNCAUGHT_CXX_EXCEPTION
as an error, which I think indicates that the problem is related to an exception thrown from C++ code (or maybe Rust code throwing a C++ exception).
I would also suspect that the issue is related to multi threading. I got a Rust backtrace that also looks like some race condition/threading issue:
thread '<unnamed>' panicked at 'already mutably borrowed: BorrowError', src/libcore/result.rs:1165:5
stack backtrace:
0: 0x7fee84531b24 - backtrace::backtrace::libunwind::trace::hc496b60554206774
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
1: 0x7fee84531b24 - backtrace::backtrace::trace_unsynchronized::ha20a82d0af0c65c5
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
2: 0x7fee84531b24 - std::sys_common::backtrace::_print_fmt::h41aff515dcee7039
at src/libstd/sys_common/backtrace.rs:76
3: 0x7fee84531b24 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9cece4375f2f7fda
at src/libstd/sys_common/backtrace.rs:60
4: 0x7fee845570ac - core::fmt::write::hecb5092b1fa0aafc
at src/libcore/fmt/mod.rs:1030
5: 0x7fee8452d057 - std::io::Write::write_fmt::h3a49fae144e74a2a
at src/libstd/io/mod.rs:1412
6: 0x7fee84533ea5 - std::sys_common::backtrace::_print::h24134367c784cf37
at src/libstd/sys_common/backtrace.rs:64
7: 0x7fee84533ea5 - std::sys_common::backtrace::print::ha95f6cb55d52824a
at src/libstd/sys_common/backtrace.rs:49
8: 0x7fee84533ea5 - std::panicking::default_hook::{{closure}}::hf48b3987cc8265dd
at src/libstd/panicking.rs:196
9: 0x7fee84533b96 - std::panicking::default_hook::h6d285b42ab8557a8
at src/libstd/panicking.rs:210
10: 0x7fee84534585 - std::panicking::rust_panic_with_hook::h694c05b962beffa6
at src/libstd/panicking.rs:473
11: 0x7fee84534122 - std::panicking::continue_panic_fmt::h6d9edb7f6134fa29
at src/libstd/panicking.rs:380
12: 0x7fee84534016 - rust_begin_unwind
at src/libstd/panicking.rs:307
13: 0x7fee845536fa - core::panicking::panic_fmt::h06aa024bca353ba1
at src/libcore/panicking.rs:85
14: 0x7fee845537f7 - core::result::unwrap_failed::hef0e5f380db2d8ff
at src/libcore/result.rs:1165
15: 0x7fee8430b4ba - discord_game_sdk::voice::get_input_mode::h40022b9fb42a1dd2
16: 0x7feefedf2eeb - Java_de_jcm_discordgamesdk_VoiceManager_getInputMode
17: 0x7fef6ef91068 - <unknown>
fatal runtime error: failed to initiate panic, error 5
It seems like creating a ReentrantLock
to prevent two SDK methods from being executed at the same time is sufficient to fix the issue for me.
But I will investigate more and see if it is also required to lock in runCallbacks
.
Edit: Nevermind, it still crashes without the lock in runCallbacks
. :sob:
I made a potential fix for this in crash-fix
.
Could you please try it out and tell me if it fixes the crash you could trigger?
Here are the built artifacts: 0.5.3.zip
after doing some testing (autoclicker on 1ms delay go brrr) I can confirm that I think this fixes that crash
That's great. Thank you for testing this out.
I'm gonna merge my changes into master
, make a new release (probably 0.5.3
) and then close this issue.
Please reopen it (or create a new one) if the initial issue is not fixed by this.
So I'm making a Minecraft mod with this and so far it has been amazing but one thing that happens out of nowhere is a crash that I think is caused by running callbacks. Here is the Java dump: