lambda-client / lambda

Minecraft utility mod coded in Kotlin
GNU Lesser General Public License v3.0
585 stars 146 forks source link

Trying to load DiscordRPC native library even if module is disabled - causing MC to crash #187

Closed graemeg closed 2 years ago

graemeg commented 2 years ago

Describe the bug I was trying to use the latest official Lambda release v2.07.01 on my FreeBSD system but it simply crashes MC. As Minecraft with Forge runs fine on my system. I tried Impact, ForgeHax and the Seppuku mods and they work just fine. Seems Lambda is trying to load a native library for Discord integration, even though I have the module disabled. This doesn't seem right.

To Reproduce

  1. Use FreeBSD 12.2 system
  2. Used MultiMC to set up a new 1.12.2 instance.
  3. Enabled Forge
  4. Add official Lamba Client
  5. Try and launch MC and it will crash due to missing discord .so native library

Expected behaviour I double checked in the default.json file, and I have the DiscordRPC disabled, but it seems Lambda is still trying to load some or other discord library regardless of enabled: false setting.

    {
      "name": "DiscordRPC",
      "settings": {
        "bind": "None",
        "enabled": false,
        "visible": true,
        "default": false,
        "priority_in_gui": 0,
        "clicks": 0,
        "line_1_left": "VERSION",
        "line_1_right": "USERNAME",
        "line_2_left": "DIMENSION",
        "line_2_right": "HEALTH",
        "coords_confirm": false
      }

Debug info

Time: 11/14/21 7:13 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Lambda (lambda)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.lambda.client.module.modules.misc.DiscordRPC
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
    at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
    at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
    at java.lang.reflect.Field.get(Field.java:393)
    at com.lambda.commons.utils.ClassUtils.getInstance(ClassUtils.kt:27)
    at com.lambda.client.module.ModuleManager.load0(ModuleManager.kt:43)
    at com.lambda.client.module.ModuleManager.load0(ModuleManager.kt:16)
    at com.lambda.client.AsyncLoader$DefaultImpls.load(Loader.kt:49)
    at com.lambda.client.module.ModuleManager.load(ModuleManager.kt:16)
    at com.lambda.client.LoaderWrapper$loadAll$1.invokeSuspend(Loader.kt:32)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at com.lambda.client.LoaderWrapper.loadAll(Loader.kt:31)
    at com.lambda.client.LambdaMod.init(LambdaMod.kt:61)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
    at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:749)
    at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196)
    at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
    at org.multimc.EntryPoint.listen(EntryPoint.java:143)
    at org.multimc.EntryPoint.main(EntryPoint.java:34)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: FreeBSD (amd64) version 12.2-RELEASE-p7
    Java Version: 1.8.0_302, OpenJDK BSD Porting Team
    Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), OpenJDK BSD Porting Team
    Memory: 2435216680 bytes (2322 MB) / 2732589056 bytes (2606 MB) up to 3818913792 bytes (3642 MB)
    JVM Flags: 2 total; -Xms2048m -Xmx4096m
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.5.2854 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID        | Version      | Source                                  | Signature                                |
    |:----- |:--------- |:------------ |:--------------------------------------- |:---------------------------------------- |
    | LCHI  | minecraft | 1.12.2       | minecraft.jar                           | None                                     |
    | LCHI  | mcp       | 9.42         | minecraft.jar                           | None                                     |
    | LCHI  | FML       | 8.0.99.99    | forge-1.12.2-14.23.5.2854-universal.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | LCHI  | forge     | 14.23.5.2854 | forge-1.12.2-14.23.5.2854-universal.jar | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | LCHE  | lambda    | 2.07.01      | lambda-2.07.01-mc1.12.2.jar             | None                                     |

    Loaded coremods (and transformers): 
LambdaMixinLoader (lambda-2.07.01-mc1.12.2.jar)

Additional context / media Let me know if there is anything else you need or debug builds I can test. I don't mind.

czho commented 2 years ago

This is one of those bugs that exists just because we didn't test it on freebsd yet, ill see what I can to get it fixed. Alot of us run linux so I know how it feels to have just random shit not be supported for basically no reason.

graemeg commented 2 years ago

Thank you very much. As I mentioned, if you need any assistance it testing, I'm more than happy to help where I can.

graemeg commented 2 years ago

Just to add. Renaming the DiscordRPC.kt (so it doesn't compile), commenting two lines in Capes.kt and removing the jarLibs Discord line in build.gradle (just for good measure)... When I then build the Lambda client, it runs just fine under FreeBSD.

3jq commented 2 years ago

Sadly, discord rpc library is currently not supported for freebsd. Maybe this issue will be solved in future.

graemeg commented 2 years ago

I honestly don't care about the DiscordRPC module (I don't need it), but if Lambda could be modified so it doesn't try and load anything Discord related, when the module is disabled, that should fix the issue. At the moment it tries to initialize the discord library, even though the DiscordRPC module is disabled - which doesn't seem right.

graemeg commented 2 years ago

Sure, here is the link: https://paste.ee/p/mycnW Log has been attached too.

latest.log

graemeg commented 2 years ago

I build and ran the latest master and plugins branches (I did the latter because I saw it had more recent commits). In both cases Lambda fails to start up under FreeBSD. I think lazy loading would be the best way to go.

huddy987 commented 2 years ago

bump, @graemeg can you please test changes

graemeg commented 2 years ago

Apologies for the delay, I've been away on work for a while. I've just tested the lazy-rpc branch and it seems to work well. :partying_face: As expected (based on what was changed in the branch) the modules still show in the menus (as it should), and now gracefully show a error without crashing the client, when I try and manually enable the Discord module.

Screenshot of the "graceful showing an error":

shot

So yeah, this seems to work perfectly under FreeBSD now. Thank you.